COSC 071: Computer Science I

Project 3
Fall 2001

Due: Nov 2 @ 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 - 18:00: $1.25 per minute.
  2. Any call started between 18:00 - 23:00: $1.00 per minute.
  3. Any call started between 23:00 - 8:00: $0.85 per minute.
The rates for domestic long distance calls are as follows:
  1. Any call started between 08:00 - 18:00 is billed at 30 cents per minute (normal rate).
  2. Any call started after 18: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 5.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-59).
Field 5: End hour (0-23).
Field 6: End minutes (0-59).

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.

Instructions for Electronic Submission: At the top of the file containing your source code (i.e., the file containing the C++ instructions), place the following header comment, with the appropriate modifications:

//
// Project 3
// Name: <your name>
// SID: <student ID>
// E-mail: <e-mail address>
// Instructor: Maloof
// TA: <TA's name>
// COSC 071-<section number>
//
// In accordance with the class policies and Georgetown's Honor Code,
// I certify that, with the exceptions of the lecture notes and those
// items noted below, I have neither given nor received any assistance
// on this project.
//
// Description: <Describe your program>
//

Although you may use any C++ compiler to develop your program, it must run under UNIX and must compile using GNU g++. When you are ready to submit your program for grading, if necessary, use ws-FTP to transfer your file from your PC to gusun. Use SSH to logon to gusun, and use pine to e-mail it to your TA with your netid and the suffix ``.cc'' as the subject. To run pine, type at the UNIX prompt:

gusun% pine

When the menu appears, select the item for composing e-mail. Assume that your netid is ab123, the name of your source file is proj1.cpp, and your TA's e-mail address is ``imagoodtamaloof@cs''.

Type your TA's e-mail address in the To field, and type your netid with the .cc suffix in the Subject field (no spaces before or after). Move the cursor down into the MESSAGE TEXT screen, and type the ^R command. Pine will ask for a file name (e.g., proj1.cpp), which it will then load as your message text. At this point, your screen should look something like the following:

Finally, type ^X to send the e-mail to your TA.

IMPORTANT: Do not send your source code as an attachment. Do not use a mail client other than pine.

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 on a university machine (e.g., gusun or cssun) 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.

The TAs who will be grading your projects this semester are listed on the main page. You must e-mail your project before 5 PM on the due date.