Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need C++ code for this programming problem. Long Distance Calls – Write a prog

ID: 663948 • Letter: I

Question

I need C++ code for this programming problem.

Long Distance Calls – Write a program that prompts the user for the starting time and the number of minutes of the call and display the charges. The charges are based on the start time of the call and use the correct rate for the time range it falls into (see table below). The start time will be entered as a floating point number (decimal) in the form HH.MM. For example, 07:00 would be entered as 07.00 and 16:28 will be entered as 16.28.

Must not accept times that are greater than 23.59 (note that 6.69 is less than 23.59 but is an invalid time).

Note the start time determines the rate, does not matter if the length of the phone call goes into another start time range.

Must not accept time whose last two digits are greater than 59.

HINT – the following expression will give you its fractional part

num – static_cast<int>(num) (where num is the start time entered by the user).

Validate that the number of minutes of the phone call is not negative

Named constants must be used for the values in the following table.

Start Time of Call

Rate Per Minute

00:00 – 05:59

0.12

06:00 – 12:59

0.23

13:00 – 19:00

0.55

19:01 – 23.59

0.35

Start Time of Call

Rate Per Minute

00:00 – 05:59

0.12

06:00 – 12:59

0.23

13:00 – 19:00

0.55

19:01 – 23.59

0.35

Explanation / Answer

#include using namespace std; int main(){ const double RATE_PER_MINUTE_MORNING = 0.12; const double RATE_PER_MINUTE_DUTY_HOURS = 0.55; const double RATE_PER_MINUTE_NIGHT = 0.35; float startTime; float totalCharge; int minutesOfTheCall; float minutes; cout > startTime; minutes = startTime - static_cast(startTime); if((startTime >= 0 && startTime = 0.0 && minutes minutesOfTheCall; if(minutesOfTheCall > 0){ if(startTime > 19){ totalCharge = minutesOfTheCall * RATE_PER_MINUTE_NIGHT; } else if(startTime >= 7){ totalCharge = minutesOfTheCall * RATE_PER_MINUTE_DUTY_HOURS; } else{ totalCharge = minutesOfTheCall * RATE_PER_MINUTE_MORNING; } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote