Question: In Java Coding ! From the Refined Algorithm Lecture, write the code from the refined algorithm that will calculate and display in minutes and hours

In Java Coding !

From the Refined Algorithm Lecture, write the code from the refined algorithm that will calculate and display in minutes and hours how long a car has been parked. Include the computed parking fees where the charges are $1.00 per hour and $1.00 for a partial hour. Print out an error message if the input is invalid.

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 double or single 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 double. d. Format as currency and print out the parking fees as follows:

You owe $xx.xx in parking fees.

3. Test your program thoroughly with the following data:

1. 65 minutes 2. 345 minutes 3. 120 minutes 4. 35 minutes 5. 0 minutes

NOTES:

1. Invalid input would be a zero or less. 2. Do not compute any fees if the input is invalid. 3. Do not print out any parking fees if the input is invalid. 4. Declare all variables within the data declaration section. 5. Do not get input on the same line as a variable declaration. 6. Do not place an equation for computation on the same line as declaring a variable.

------------------------------------------------------------------------------------------------------------------------------------- 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 END IF

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!