I'm trying to get this code to work but it will only ask for the first number to be entered again. Anytime the first number is below 10 or above 99 it will ask for the first number to be entered, but as soon as the second number is entered outside of the range it will just print the error message and ask for the third number without again requiring input for the second. This happens again for the third number. Do I need a loop encompassing all of these inputs? Should the boolean "ok" be reset as false after each input number? Any ideas as to why would be greatly appreciated. Thanks.
public void setCoefficients() { Scanner inputDevice = new Scanner(System.in); JOptionPane.showMessageDialog(null, "Welcome to the lottery game! "); do { System.out.println("Please enter your first number between 10 and 99: "); a = inputDevice.nextInt(); if(a<10||a>99) System.out.println("Please enter a number between 10 and 99 "); else ok=true; }while(!ok); do { System.out.println("Please enter your second number between 10 and 99: "); b = inputDevice.nextInt(); if(b<10||b>99) System.out.println("Please enter a number between 10 and 99 "); else ok=true; }while(!ok); do {System.out.println("Please enter your last number between 10 and 99: "); c = inputDevice.nextInt(); if(c<10||c>99) System.out.println("Please enter a number between 10 and 99 "); else ok=true; }while(!ok); }