COSC 071: Computer Science I

Project 3
Spring 2000

Due: Mar 29 @ 5 P.M.
9 points

Saxa Communications, a new telephone company, needs a billing system for its domestic and international service. The rate structure for international calls is as follows:

  1. Any call started between 08:00 - 17:00: $1.25 per minute.
  2. Any call started between 17:00 - 23:00: $1.00 per minute.
  3. Any call started between 23:00 - 8:00: 75 cents per minute.
The rates for domestic long distance calls are as follows:
  1. Any call started between 08:00 - 17:00 is billed at 30 cents per minute (normal rate).
  2. Any call started after 17:00 is discounted by 30% of the normal rate.
  3. Any call longer than 60 minutes receives a 20% discount on the normal rate and on any other discounted rate.

For both international and domestic calls:

  1. The rate remains the started rate regardless of when the call ends.
  2. All phone calls are subject to 4.5% federal tax.
  3. No call will be longer than 24 hours.
Write a program to produce a phone bill calculating the total amount (including tax) of billed calls. An input file contains the phone calls a customer has made over a one month period. The phone bill should be in the following format:
Date  Time of Call  Length  Charge   Message

XX    XX:XX         XXX     XXX.XX   XXXXXXXXXXXXXXX
XX    XX:XX         XXX     XXX.XX   XXXXXXXXXXXXXXX
...

Subtotal:                 $ XXX.XX
Tax:                        XXX.XX
Total:                      XXX.XX
The Message field should be used to display error messages regarding the call. At the very least, use functions to determine whether a call is valid and to process the two types of calls. Use comments to document each function. Choose appropriate parameters for the functions. You may use global constants, but do not use global variables. You may use literals for quantities that will never change, like the number of minutes in an hour, but you should represent all other quantities, like the federal tax rate, as constants. A rule of thumb for where to declare constants is if the constant is used within one function, then declare the constant within that function; otherwise, declare it globally.

You'll need to create your own input file for this project. It must be named 'proj3.dta'. The TAs will test your program on an input file with an unknown number of records, each having the following format:

Field 1: Day of the month (1-31)
Field 2: call type, I for international calls, D for domestic calls.
Field 3: Start hour (0-23).
Field 4: Start minutes (0-60).
Field 5: End hour (0-23).
Field 6: End minutes (0-60).

Fields are separated by spaces.

You can assume that the valid days of the month will be order consequtively. However, your program ensure that the values in each field are valid and take the appropriate action if they are not.

Examples of calls include but are not limited to the following:

3 D 18 32 20 15
represents a domestic call made on the third day of the month starting at 18:32 and ending at 20:15.
5 I 23 58 0 10
represents an international call made on the fifth day of the month starting at 23:58 and ending at 0:10 the next morning.
30 I 23 70 26 12
represents an international call but should generate an error message that is descriptive of the detected problem and should not be counted in billing. In this example, the ending minutes are not within the valid range.

At the top of the file containing your source code, place the following header comment, with the appropriate modifications:

//
// Project 3
// Name: <your name>
// SID: <student ID>
// E-mail: <e-mail address>
// Instructor: (Cole or Maloof)
// TA: <TA's name>
// COSC 071-<section number>
//
// Description: <Describe your program>
//

Instructions for Submission: All programs must run under Unix and must compile using GNU g++. When you are ready to submit your program for grading, e-mail it to your TA using the last four digits of your student ID and the suffix ``.cc'' as the subject line.

For example, if the last four digits of your student ID is 1234, the name of your source file is proj1.cc, and your TA's e-mail address is ``imagoodta@georgetown.edu'', then you would type at the Unix prompt:

gusun% mailx -s "1234.cc" imagoodta@georgetown.edu < proj1.cc
You are executing the mailx command. The -s option indicates that the string "1234.cc" is the subject heading. imgagoodta@georgetown.edu is the address to which the mail will be sent. The part ``< proj1.cc'' takes your source file and directs it into the mailx command.

You can also use pine to submit your project. After filling in the To and Subject fields, type the ^R command in the MESSAGE TEXT screen. Pine will ask for a file name, which it will then load as your message text. Type ^X to send the e-mail.

You must submit your project by e-mail before 5:00 P.M. on the due date.

If you need to include a message to you TA about your submission, then type the message as a comment in the program.

Once you've submitted your project, it is important to keep an electronic copy that preserves the modification date and time. If we lose your project or the e-mail system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.