Question: my code works but I don't get why, should it not be the opposite way? that if entered "Yes" or "No" the System.out.println("You must write 'Yes' or 'No'") should appear in the console?
Please explain for a dummie how/why it works this way.
import java.util.Scanner;
public class YesOrNo {
public static void main(String[] args) {
// Checkpoint 4.6 Write an input validation loop that asks the user to enter “Yes” or “No”.
String Input;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter Yes or No: ");
Input = keyboard.nextLine();
while (!Input.equals ("Yes") && !Input.equals ("No")){
System.out.println("You must write 'Yes' or 'No'");
}
System.exit(0);
}
}