0
Why is not work? Exercise with do while
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner read = new Scanner(System.in); int password; do { password = read.NextInt(); if (password != 8819) { System.out.println ("Write password"); } } while (password == 8819); } }
4 odpowiedzi
+ 1
password = read.nextInt(); // .NextInt()
Is 8819 the correct password or not? I had to ask cause I can see the loop condition specifies `while( password == 8819 );`
+ 1
Then the loop condition should be
while( password != 8819 );
This way loop stop repetition once <password> equals 8819.
+ 1
Thanks
0
8819 correct password