Sie sind auf Seite 1von 5

ASSIGNMENT NO.

CELLULAR TELEPHONE BILLING PROGRAM

FRISNEDI, NADINE T.

PROF.
GENNESIS JOY G. CEREDON

JANUARY 30, 2014


1

MAIN PROBLEM
Write a program that calculates and prints the bill for a cellular telephone
company. The company offers two types of service: regular and premium. Its rates vary,
depending on the type of service. The rates are computed as follows:
Regular service: $10.00 plus first 50 minutes are free. Charges for over 50
minutes are $0.20 per minute.
Premium service: $25.00 plus:
1. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free;
charges for more than 75 minutes are $0.10 per minute.
2. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are
free; charges for more than 100 minutes are $0.05 per minute.
Your program should prompt the user to enter an account number, a service code
(type char), and the number of minutes the service was used. A service code of r or R
means regular service; a service code of p or P means premium service. Treat any other
character as an error. Your pro- gram should output the account number, type of service,
number of minutes the telephone service was used, and the amount due from the user.
For the premium service, the customer may be using the service during the day
and the night. Therefore, to calculate the bill, you must ask the user to input the number
of minutes the service was used during the day and the number of minutes the service
was used during the night.
PROBLEM ANALYSIS

The purpose of this program is to calculate and print the billing amount. To calculate the billing
amount, you need to know the customer for whom the billing amount is calculated (whether the
service is regular or premium) and the number of minutes the customer uses. In the case of

a premium service, you also need to know the number of minutes used for the day and
night. Other data needed to calculate the bill, the cost of a premium channel, and
additional cost if the free minute is already used are known quantities. The program
should print the billing amount to two decimal places, which is standard for monetary
amounts. This problem analysis translates into the following algorithm:

Algorithm Design
1. Use constants. This will be used when computing for the bill. Use constants for
the service cost of regular and premium and other constants for additional costs.
2. Set variables for all.
3

3. Set the precision to two decimal places. To output floating-point numbers in a


fixed decimal format with a decimal point and trailing zeros, set the manipulators
fixed and showpoint. Also, to output floating-point numbers with two decimal
places, set the precision to two decimal places. Recall that to use these
manipulators, the program must include the header file iomanip.
4. Prompt the user for the account number.
5. Prompt the user for the service type.
6. Based on the customer type, use the if and else statements.
a. If service type is r or R
Determine the number of minutes used
If less than or equal to 50, amount due is equal to basic service cost.
If more than 50 multiply the excess minutes to the additional cost.
Then add to the basic service cost
Compute the bill
Print the bill:
b. If the service type is P or p,
Prompt the user to enter the number of minutes used for the day
If less than or equal to 75, amount due is equal to basic service cost.
If more than 75 multiply the excess minutes to the additional cost.
Prompt the user to enter the number of minutes used for the night
If less than or equal to 100, amount due is equal to basic service cost.
If more than 100 multiply the excess minutes to the additional cost.
Total due is amountDue1 + amountDue2 basic service cost
Compute the bill
Print the bill
8. If inputed invalid character

Show error message.

Screenshot of the working program

Das könnte Ihnen auch gefallen