• 09-05-2012, 07:02 PM
orgmiri
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 an application that calculates and displays the parking charges for each customer who parked in the garage yesterday. You should enter the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the running total of yesterday's receipts. The program should use the method calculateCharges to determine the charge for each customer.

import java.util.Scanner;

public class exercise2Method {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("pleasa input total time: ");
double totalTime = input.nextDouble();

System.out.printf("Volume is %f\n", calculateCharges( totalTime ));
}
public static double calculateCharges( double totalTime ){

double addHour = totalTime - 3.00;
double total = totalAddHour + 2;

if( totalTime <= 3.00 ){
System.out.println("you must pay RM 2.00");

}

if( totalTime > 3.00 ){
System.out.printf("you must pay RM "+ total);

}
if( totalTime >= 24 ){
System.out.printf("you must pay RM 10.00");

}