Here's the challenge description: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 in the garage yesterday.  Input the number of hours parked for each customer. The number of customers can be fixed using a final constant.The program should display the charge for the current customer and should calculate and display the running total of the day's receipts.  Use a method called calculateCharges to determine the charge for each customer.Here's my code:import java.text.DecimalFormat;import java.util.Scanner;public class Hwk4B {    public static void main(String[] args)     {        Scanner keyboard = new Scanner(System.in);        DecimalFormat formatter = new DecimalFormat($##.00);        System.out.print(Enter the number of cars parked yesterday: );        final int NUMBER_OF_CARS = keyboard.nextInt();        double hoursParked=0;        double currentCost=0;           double totalCost=0;        for(int count = 1; count<=NUMBER_OF_CARS; count++)        {               System.out.print(Enter hours parked for car  + count + : );            hoursParked = keyboard.nextDouble();            currentCost = calculateCharges(hoursParked); //most recent customer            totalCost+=currentCost; //Running total        }        System.out.println(Most recent customer paid:    +  formatter.format(currentCost));        System.out.println(Running total of receipts:  + formatter.format(totalCost));    }    public static double calculateCharges (double numHours)    {        double garageCost = 0;        if(numHours<=3)            garageCost = 2;        else if(numHours>3 && numHours<=19)            garageCost = 2.0 + 0.5*(numHours - 3);        else if (numHours >19)            garageCost = 10;        return garageCost;    }}
Calculating Parking Fees
java
You're inconsistent with how you place your curly braces, {}. The general style for Java is to place opening curly braces, {, on the same line, like this:public void myMethod() {}This goes for loops, classes, if statements, etc.Even though for one-liner if statements, curly braces aren't necessary, I'd still recommend using them. This means that a statement like this:if (numHours<=3)    garageCost = 2;Would become this:if (numHours<=3) {    garageCost = 2;}Not using curly braces can lead to some not so great mistakes happening. A famous example of this is the Apple SSL bug. This is what happened:if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)    goto fail;    goto fail;  /* MISTAKE! THIS LINE SHOULD NOT BE HERE */Note the lack of curly braces.I'm also noticing inconsistencies with spacing. For example, this:else if (numHours>3 && numHours<=19)Should be changed to this:else if (numHours > 3 && numHours <= 19)Generally, it's best to have whitespace between comparison, boolean, binary, mathematical, and assignment operators. It makes your code much clearer, and cleaner to read.Finally, rather than using concatenation to format strings, I'd use System.out.printf instead. Here's an example:System.out.printf(Most recent customer paid: %s\n, formatter.format(currentCost));System.out.printf(Running total of receipts: %s\n, formatter.format(totalCost));Here's another example:System.out.printf(Enter hours parked for car %d: , count);If you don't like System.out.printf, you can always use String.format.