UMBC CS 201, Spring 00
UMBC CMSC 201 Spring '00 CSEE | 201 | 201 S'00 | lectures | news | help

CMSC 201
Programming Project One

B & F Internet Service Providers

Out: Wednesday 2/9/00
Due: Before Midnight, Sunday 2/20/00

The Objective

The objective of this assignment is to get you started writing programs in C in the UNIX environment. This project will give you practice using loops, and mixing data types.

The Background

The B & F Internet Service provides connections to the internet for home, school and business. B & F offers the most reliable connection service available 24 hours per day, 7 days per week and provides unmatched customer service.

To provide this world class service, B & F charges connection fees by the minute. The per minute fee depends upon the time of day you are connected, according to the following table

Time of DayFee per Minute
Midnight - 6:00 AM 0.02
6:00 AM - 12:00 Noon 0.03
12:00 Noon - 6:00 PM0.05
6:00 PM -Midnight PM0.06

The Task

You have been employed by B & F to write a program to calculate customer's fees. Your task is to write a program that inputs user connect start times and end times and calculates the connection fee. Your program should input both the start time and stop time on the same line. You should continue to accept input until the user types in 0 for BOTH the stop time and the start time.

To make it easier to differentiate between AM and PM, all times will be input as military time. Military time uses a 24-hour clock, so there is no AM or PM specification and does not use a colon (:) between the hours and minutes. This is accomplished by adding 12 to the hours between noon and midnight. The table below shows the correspondence between "regular" time and military time.

RegularMilitary RegularMilitary
Midnight0000 Noon1200
1:00 AM0100 1:00 PM1300
2:00 AM0200 2:00 PM1400
3:00 AM0300 3:00 PM1500
4:00 AM0400 4:00 PM1600
5:00 AM0500 5:00 PM1700
6:00 AM0600 6:00 PM1800
7:00 AM0700 7:00 PM1900
8:00 AM0800 8:00 PM2000
9:00 AM0900 9:00 PM2100
10:00 AM1000 10:00 PM2200
11:00 AM1100 11:00 PM2300
Some examples

1:35 PM would be entered as 1335 4:03 AM would be entered as 0403 Midnight would be entered as 0000 10:30 PM would be eneterd as 2230 After all connection start times and end times have been entered, your program will display the number of minutes and fee amount for each different fee period followed by the total user fee. See the sample output below.

Assumptions

Because this is your first assignment for B & F, the supervisors are allowing your program to make some assumptions that will make your program easier to write
  1. Knowledgeable users will not enter invalid data
    This means
  2. All user connect time will occur in the same day. This means that no user connect time will start before midnight and end after midnight.

Hints

  1. Note that it is possible for a single user connection to use time in 2 (or more) different fee periods.
    For example, a user whose start time is 4:00 PM (1600) and whose end time is 6:30 PM (1830) will be charge 2 hours (4:00 PM to 6:00 PM) at 5 cents per minute and 30 minutes (6:00 PM to 6:30 PM) at 6 cents per minute.
  2. This project will be easier if you think of time as "minutes since midnight" rather than hours and minutes or time of day
  3. While scanf will handle leading zeros on input, (i.e. typing 0600 is the same as typing 600), the same is not true in our code. Remember that 0600 is an octal (base 8) constant, NOT the same as 600 (a base 10 constant).

Sample Run

sunserver1[102] a.out Welcome to the B & F ISP Connection Fee Calculator Please enter connection start time and end time on the same line in 24-hour military time Enter BOTH start and stop time as 0000 to quit Please enter start time & stop time: 0100 0330 Please enter start time & stop time: 0000 0000 Your connection time and fees: 150 minutes at 0.02 cost $ 3.00 0 minutes at 0.03 cost $ 0.00 0 minutes at 0.05 cost $ 0.00 0 minutes at 0.06 cost $ 0.00 ------------------------------------ Total Cost: $3.00 sunserver1[103] a.out Welcome to the B & F ISP Connection Fee Calculator Please enter connection start time and end time on the same line in 24-hour military time Enter BOTH start and stop time as 0000 to quit Please enter start time & stop time: 0500 0630 Please enter start time & stop time: 0000 0000 Your connection time and fees: 60 minutes at 0.02 cost $ 1.20 30 minutes at 0.03 cost $ 0.90 0 minutes at 0.05 cost $ 0.00 0 minutes at 0.06 cost $ 0.00 ------------------------------------ Total Cost: $2.10 sunserver1[104] a.out Welcome to the B & F ISP Connection Fee Calculator Please enter connection start time and end time on the same line in 24-hour military time Enter BOTH start and stop time as 0000 to quit Please enter start time & stop time: 0530 0630 Please enter start time & stop time: 0700 0800 Please enter start time & stop time: 1150 1210 Please enter start time & stop time: 1730 2100 Please enter start time & stop time: 0000 0000 Your connection time and fees: 30 minutes at 0.02 cost $ 0.60 100 minutes at 0.03 cost $ 3.00 40 minutes at 0.05 cost $ 2.00 180 minutes at 0.06 cost $ 10.80 ------------------------------------ Total Cost: $16.40 sunserver1[105] a.out Welcome to the B & F ISP Connection Fee Calculator Please enter connection start time and end time on the same line in 24-hour military time Enter BOTH start and stop time as 0000 to quit Please enter start time & stop time: 0100 2300 Please enter start time & stop time: 0000 0000 Your connection time and fees: 300 minutes at 0.02 cost $ 6.00 360 minutes at 0.03 cost $ 10.80 360 minutes at 0.05 cost $ 18.00 300 minutes at 0.06 cost $ 18.00 ------------------------------------ Total Cost: $52.80 sunserver1[106]

Although your output need not be identical to the above, all information (including the greeting) must be present.

Submitting the Program

Your C source code file for this project MUST be called proj1.c.
To submit your project, type the following at the Unix prompt. Note that the project name starts with uppercase 'P'.

submit cs201 Proj1 proj1.c

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.

submitls cs201 Proj1


CSEE | 201 | 201 S'00 | lectures | news | help

Tuesday, 08-Feb-2000 23:11:41 EST