The problem is that you call nextInt() in all ifs. This way you basically wait for another input each time you call passwordInput.nextInt().
Try to save the user input and then check it for the password. Something like:
if (passwordInput.hasNextInt()) {
int pass = passwordInput.nextInt();
if (pass == builtInPassword) {
System.out.println("Your password is correct.");
} else {
System.out.println("The password entered is incorrect");
}
} else {
System.out.println("Sorry, please enter the right format");
}
I am writing without a compiler here so I am not sure it will compile properly but you can get the idea ;)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…