Hi, I have this code but for some reason the nextLine() does not get executed, any ideas on why? Any help would be great, thanks.
Code:
public static void menu() {
Tester getQuestion = new Tester();
Scanner input = new Scanner(System.in);
while(Quit == false) {
System.out.println("Please enter the corresponding menu option:");
System.out.println("1. 1st Grade");
System.out.println("2. 2nd Grade");
System.out.println("3. Quit the Program");
System.out.print("Enter: ");
int value;
String cont = "";
value = input.nextInt();
if(value == 3) {
Quit = true;
}
else if (value == 1 || value == 2) {
getQuestion.GradeOneQuestion();
System.out.print("Play again? (Y or N) ");
cont = input.nextLine(); //---------This is the part that doesn't work
System.out.println("Input was: " + cont);
if(cont == "N")
Quit = true;
}
}
else {
System.out.println("Incorrect number, please type again");
}
}
}
Last edited: