Question: In C++ Programming, USE IF/ELSE ONLY Using the Refined Algorithm in this lecture, write the code from this Refined Algorithm that will calculate and display

In C++ Programming, USE IF/ELSE ONLY

Using the Refined Algorithm in this lecture, write the code from this Refined Algorithm that will calculate and display in minutes and hours how long a car has been parked. Include the parking fees where the charges are $1.00 per hour and $1.00 for a partial hour.

You must include the following:

1. IF the User enters 0 minutes, print a message letting them know they did not enter a valid parking time.

2. ELSE the User entered minutes greater than 0 then do the following:

a. Keep the hours and minutes as integers. Do not use floats for these values. b. Print out the hours and minutes as follows:

Your car has been parked for x hours and x minutes.

c. Calculate the parking fee as a float. d. Format the fee with set precision of 2 decimal places and print out the parking fee as follows:

You owe $xx.xx in parking fees.

3. Test your program thoroughly with the following data:

1. 59 minutes 2. 60 minutes 3. 61 minutes 4. 120 minutes 5. 121 minutes 6. 345 minutes 7. 0 minutes (only the error message should print)

4. Do not forget to use system("pause") to pause the output screen.

NOTE: 1. Declare all variables within the data declaration section. 2 Do not get input on the same line as a variable declaration. 3. Do not place an equation for computation on the same line as declaring a variable.

(The refined algorithm)

Create a Refined Algorithm:

We start with the Initial Algorithm and fill in the details of HOW each step will be executed to create our Refined Algorithm.

1. Get the total number of minutes parked:

o Input totalMinutes.

2. IF the totalMinutes is equal to zero THEN

o Output an error message stating that the number of minutes is invalid.

3. ELSE.

o Compute the total hours parked:

hoursParked = totalMinutes / 60

o Compute the left over minutes parked:

minutesParked = totalMinutes % 60

o Compute the parking fee for the number of hours parked:

parkingFee = hoursParked * 1.00

o IF minutesParked is greater than zero THEN

parkingFee = parkingFee + 1.00

o Display the parkingFee

4. END IF

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!