conditional statementsquestion 1 write a program


Conditional Statements

Question 1: Write a program that computes the cost of a long distance call. The cost of the call is determined according to the following rate schedules.

  • A call made between 8:00 AM and 6:00 PM is billed at a rate of 6 rupees per minute.
  • A call made before 8:00 AM or after 6:00 PM is charged at a rate of 3.75 rupees.

According to this schedule, if a call starts at any time between 8:00 AM and 6:00 PM, and it ends after 6:00 PM then it will be charged at the rate of 6 rupees per minute for the time before 6:00 PM and for the rest of the time the rate will be 3.75 rupees per minute. For example if a call 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.      

After completing the program test it for following inputs.

Input

Output

Start time

Length

Cost

8: 21

10

60

17:55

10

 

7:49

12

 

6:00

30

 

8:00

5

 

Question 2: You are required to modify the program written for calculating call charges according to the following schedule.

  • Any call made between 8:00 AM and 6:00 PM, Monday through Friday, is billed at a rate of 6 rupees per minute.
  • Any call made before 8:00 AM or after 6:00 PM, Monday through Friday, is charged at a rate of 3.75 rupees per minute.
  • Any call made on a Saturday or Sunday is charged at a rate of 1.5 rupees per minute.

The modified program will also input the day of the week along with the other inputs. The day of the week will be read as one of the following pairs of character values, which are stored in two variables of type char:

Su                  Tu Th Sa                           We Fr Su

 

The rules for calculating the charges for a call are same as in the previous program with following enhancements.

If a call is started on Friday at 11:55 PM and ends at 12:05 AM on Saturday then the rate of the call will be calculated as cost of call as per schedule on Friday for first 5 minutes, plus the cost of call as per schedule on Saturday for rest of the 5 minutes. Similarly, if a call starts on Sunday at 11:55 PM and ends at 12:05 AM on next day i.e. Monday, then the cost of the call will be calculated as charges as per schedule on Sunday plus the charges as per schedule on Monday.

After completing the program test it for following inputs.

Input

Output

Start time

Length

Day

Cost

8: 21

10

Monday

60

17:55

10

Tuesday

 

7:49

12

Friday

 

6:00

30

Sunday

 

23:55

10

Friday

 

23:51

20

Sunday

 

 

 

 

 

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: conditional statementsquestion 1 write a program
Reference No:- TGS0482283

Expected delivery within 24 Hours