According to this schedule, if a call starts at any time between 8:00 AM and 6:00 PM, and it ends starts at 5:55 PM and ends at 6:05 PM then the charges on this call will be 48.75 (30 rupees for first 5 minutes and 18.75 rupees for rest of the time).
Similarly if a call starts at the time before 8:00 AM but ends after 8:00 AM then it will be charged at the rate of 3.75 rupees for the time before 8:00 AM and for remaining minutes after 8:00 AM the rate will be 6 rupees per minute. For example if a call starts at 7:49 AM and ends at 8:01 AM the charge on that call will be 47.25 rupees (41.25 for first 11 minutes and 6 rupees for last minute).
The input to the program will consist of the time the call started, and the length of call in minutes. The output will be the cost of call. The time is to be input in 24-hours notation, so the time 1:30 PM is input as 13:30. The time will be input using two variables of type int, one used for hour and other used for minutes. The number of the minutes for length of the call will also be input as a value of type int.
The solution to this exercise can be divided into two parts as explained below. This will make your task easier.
Part 1: Calculating End Time of Call
Input: Start time (Hour, Minutes) and Length
Output: End time (Hour, Minutes)
In this part you need to calculate the end time of the call. This part of the program will need Start time of the call and Length of the call as input. The output of this part of program is End Time of the call (The end time will also be represented by two integer variables, one for hour and other for minutes). The output of this program will be needed in the second part of the program which is described below.
Part 2: Calculating the Cost of Call
Input: End time (Hour, Minutes) – Calculated in Part 1
Output: Cost of Call
The input to this part of the program will be the value of End Time calculated in part 1, as described above. Using the variable values resulting from part 1, this part will calculate the final output of the program i.e. Cost of the call.
*Test your program for the following set of inputs, no need to test any other case.
Sample Output:
Enter starting hour: 3
Enter starting min: 45
Enter length: 63
Ending hour and min is 4: 48
Call charges are 236.25
Enter starting hour: 7
Enter starting min: 55
Enter length: 10
Ending hour and min is 8: 5
Call charges are 48.75
Enter starting hour: 7
Enter starting min: 49
Enter length: 12
Ending hour and min is 8: 1
Call charges are 47.25
Enter starting hour: 16
Enter starting min: 20
Enter length: 120
Ending hour and min is 18: 20
Call charges are 675.00
Enter starting hour: 21
Enter starting min: 20
Enter length: 15
Ending hour and min is 21: 35
Call charges are 56.25
-1
