So I want to make it so that if you give a specific answer to a question, it skips the other questions This is currently my code
System.out.print("How old are you? ");
int age = Integer.parseInt(scanner.nextLine());
System.out.print("Do you already have a scooter license? ");
String scooter = scanner.nextLine();
System.out.print("Do you already have a car license? ");
String auto = scanner.nextLine();
if (age >= 17 && auto.equals("no") || age >= 17 && auto.equals("No")) {
System.out.println("You can get a car license.");
} else if (age >= 17 && auto.equals("yes") || age >= 17 && auto.equals("Yes")){
System.out.println("You can also buy a scooter.");
} else if (age == 16 && scooter.equals("no") || age == 16 && scooter.equals("No")) {
System.out.println("You can get a scooter license.");
} else if (age == 16 && scooter.equals("yes") || age == 16 && scooter.equals("Yes")) {
System.out.println("You can get a car license next year.");
} else if (age < 16) {
System.out.println("When you are 15.5 years old you can do your written exam for a scooter license.");
System.out.println("And when you're 16 you can get a scooter license.");
}
}
So what I want is that when you answer anything under 16 to the first question, that you skip the other 2 questions.
And if you answer 16 to the first question, you skip the 3rd question.
And if you answer 17 or higher to the first question you skip the 2nd question.
Can you help me?
Aucun commentaire:
Enregistrer un commentaire