What im trying to do: Trying to make a parking ticket machine that will check if the user is a member if the user is they will be ticketed 2.00 if not 3.00 with a discount of 2.50 after 12hrs, also the machine should round the number of hour Partial hours are rounded up to the next hour. Also trying to add data validation for time parked exp user cant enter 0 hours or a negative hr. I cant get my script to add 2 decimal places it comes out as 1 decimal place.
//Import Scanner import java.util.Scanner; public class Undergroundparking2 { public static void main(String[] args) { System.out.println("WELCOME TO THE UNDERGROUND PARKING GARAGE"); System.out.println("-----------------------------------------"); //Asking user if they own a membership card System.out.println("Do you own a membership card (Y or N)?"); membership = input.nextLine(); //Selection statement for if yes is entered if (membership.equalsIgnoreCase("Y")) { System.out.print("Enter Number of hours: "); hr = input.nextDouble(); System.out.println("**********Charges**********"); System.out.println("Parking for Members"); if (hr > 50) { System.out.println("Your total charge is $100.00" + df.format(amount)); } else { double amount = (hr) * 2.00; System.out.println("Charges= " + df.format(amount)); } }