## snowball14

Can anyone tell me what I am doing wrong? I can't get it to calculate the charges.

## stultuske 1,092

Can anyone tell me what I am doing wrong? I can't get it to calculate the charges.

what you're doing wrong?

## jwenting 1,649

well, maybe he has nothing to post, in which case there's nothing to do the calculation :)

commented: Haha! +5

## snowball14

``````import java.util.Scanner;

public class Garage {
Scanner input = new Scanner(System.in);
int  customerNumber = 1;
double totalParkingReceipts =0.0;
double parkingCharge;
double hoursParked;
String hoursParkedPrompt= "Enter number of hours parked for customer %2d, or <ctrl>z to stop:_";
String programOutput= ("\nSummary of Today's Receipts:\n");
programOutput += String.format("\n\t%8s   %6s   %7s","Customer","Hours ","Parking");
programOutput += String.format("\n\t%8s   %6s   %7s"," Number ","Parked","  Fee  ");
System.out.println("Task 09-02, Ch06, Programmed by Pam Thomas\n");
System.out.println("Parking Attendent Activity\n");
System.out.printf("\t                                   " + hoursParkedPrompt, customerNumber);
while (input.hasNext()){
hoursParked=input.nextDouble();
parkingCharge=calculateCharge(hoursParked);
totalParkingReceipts += parkingCharge;
programOutput += String.format("\n\t%8d   %6.1f   \$%6.2f", customerNumber, hoursParked, parkingCharge);
System.out.printf("\tCharge for customer %2d is \$%6.2f; "+hoursParkedPrompt, customerNumber, parkingCharge, ++customerNumber);
} //end while
programOutput += String.format("\n\t%-17s   \$%6.2f","   Total Reciepts", totalParkingReceipts);
System.out.println(programOutput);
System.out.println("\nEnd of program");
} // method main
private static double calculateCharge(double hoursParked) {
final double minimumParkingCharge= 2.0;
final double maximumParkingCharge= 10.0;
final double maximumParkingHoursForMinimumParkingCharge= 3.0;
final double chargePerHourAfterMinimum= 0.5;
double parkingCharge;
parkingCharge= minimumParkingCharge;
if (hoursParked > maximumParkingHoursForMinimumParkingCharge);
parkingCharge = minimumParkingCharge + chargePerHourAfterMinimum +  Math.ceil(hoursParked - maximumParkingHoursForMinimumParkingCharge);
// End If
if (parkingCharge > maximumParkingCharge);
parkingCharge = maximumParkingCharge;
//End IF
return parkingCharge;
} // method calculateCharge
} // class Garage

import java.util.Scanner;
public class GarageTest{
public static void main(String args[]){
Garage myGarage=new Garage();