Friday, March 7, 2014

timeApp

**POSTPONED SINCE I NEED MORE INFO**


CMPS 1044 Program 3 Spring 2014 –  Long-Distance Calls


Problem solving steps & Manually Calculated Answers

Problem Description
A long-distance carrier charges the following rates for telephone calls between the U.S. and Mexico:

Starting time of Call (hour:minutes)
Rate Per Minute
00:00 06:59 (midnight 6:59 a.m.)
$ 0.12
07:00 19:00 (7 a.m. – 7 p.m.)
0.55
19:01 23:59 (after 7 p.m. before midnight)
0.35

Given the StartTime of a call and the Length of the call in minutes, the cost for the call is to be calculated.  The time is input as a decimal number. That is, 5:45 will be input as 5.45.  You MUST split this into the integer Hour and Minute components then validate the correct format of each one. When printing, you must print the time as 05:45, with the colon not the period.  Use a while loop counting to 17, like you did in the first 2 programs. ** Use if statements, properly nested, to solve the problem.  All I/O is to be file based.

Data File ( Name, StartTime, Length (in minutes))
Mary
5.45
10
Joe
16.41
40
Ted
23.10
38
Joshua
45.9
2
Fred
12.42
50
Caroline
23.00
121
Jeffrey
19.00
82
Joy
24.00
13
Paul
06.59
8
Tony
7.00
29
Henry
19.01
59
Catherine
23.08
134
Titus
10.60
65
Julio
5.37
100
Rebekah
12.03
81
Andy
23.59
5
TalkMonkey
22.00
300

Input Validation:  You must check Hour & Minute after reading it in.  That is, if Hour is greater than 23 or if Minute is greater than 59, then you will print the word ERROR in the CHARGE column. Otherwise, you calculate and print the total cost.

Output Form:  Make sure that your output looks as below.
Your Name

Long Distance Telephone Bills
Name   Start Time Length    Charge
-------------------------------------------------------- David     12:42    100      $ 55.00   NOTE: Alignment
Julie     06:05     10      $  1.20   NOTE: Must manually print 0
Max       25:50     12        ERROR        for single digit times.
Cindy     12:89    100        ERROR


No comments:

Post a Comment