I am working in the ParkingCarSimulator programming challenges of the starting out with java book but I found a problem and I can't really see what is wrong, it seems right and the same than all the other ones. So I am getting the user to input values for officer name, officer badge, car make, car model, etc. The program is compiling good and seems fine but when you run it and start entering the info, you will notice that entering the info for the officer name is good, same for the officer badge but next should be car's make but it just skips that and goes into car's model and I can't really see why, any ideas? here is the code(check 3rd println):
public class ParkingCarSimulator {
public static void main(String[] arsg)
{
String officerName, Make, carModel, carColor, carLicense;
int badgeNumber, minOnCar, minPurchased;
double fine = 0;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the officer's name");
officerName = keyboard.nextLine();
System.out.println("Enter officer's badge number");
badgeNumber = keyboard.nextInt();
System.out.println("Enter the car's make");
Make = keyboard.nextLine();
System.out.println("Enter the car's model");
carModel = keyboard.nextLine();
System.out.println("Enter the car's color");
carColor = keyboard.nextLine();
System.out.println("Enter the car's liscence number");
carLicense = keyboard.nextLine();
System.out.println("Enter minutes on car");
minOnCar = keyboard.nextInt();
if(minOnCar <= 0) {
System.out.println("Invalid Entry. Please try again.");
minOnCar = keyboard.nextInt();
}
System.out.println("Enter the number of minutes purchased");
minPurchased = keyboard.nextInt();
if(minPurchased <= 0) {
System.out.println("Invalid Entry. Please try again.");
minPurchased = keyboard.nextInt();
}
if(minOnCar > minPurchased) {
fine = 25.0;
}
if(minPurchased < minOnCar) {
System.out.println("Car parking time has expired");
System.out.println("\nTicket Data:");
System.out.println("\nMake: " + Make);
System.out.println("\nModel: " + carModel);
System.out.println("\nColor: " + carColor);
System.out.println("\nLiscence Number: " + carLicense);
System.out.println("\nOfficer Name: " + officerName);
System.out.println("\nBadge Number: " + badgeNumber);
System.out.println("\nFine: " + fine);
} else {
System.out.println("The car parking minutes are valid");
}
}
}