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

A parking garage charges a $2.00 minimum fee to park for up to three hours. The

ID: 3641132 • Letter: A

Question

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an
additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge
for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time.
Write a Java program that calculates and displays the parking charges for each customer who parked a
car in this garage. Your program should ask input from the user the hours parked for each customer. The
program should display the charge for the current customer.
Sample test run results
Hours parked : 3
Your parking charge is $2.00
Hours parked : 8
Your parking charge is $4.50
Hours parked : 23
Your parking charge is $10.00

Explanation / Answer

please rate - thanks

import java.util.*;
public class main
{ public static void main(String args[])
{Scanner in = new Scanner(System.in);
double hours,charge;
System.out.print("Hours parked: ");
hours=in.nextInt();
charge=2;           //minimum charge;
if(hours>3)
    charge =2.+(hours-3.)*.5;
if(charge>10)
        charge=10;
System.out.printf("Your parking charge is $%.2f ",charge);


}
}

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