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); } }

22nd Feb 2022, 12:54 PM
Віталік Чиковський
Віталік Чиковський - avatar
4 Answers
+ 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 );`
22nd Feb 2022, 1:02 PM
Ipang
+ 1
Then the loop condition should be while( password != 8819 ); This way loop stop repetition once <password> equals 8819.
22nd Feb 2022, 1:13 PM
Ipang
+ 1
Thanks
22nd Feb 2022, 1:23 PM
Віталік Чиковський
Віталік Чиковський - avatar
0
8819 correct password
22nd Feb 2022, 1:09 PM
Віталік Чиковський
Віталік Чиковський - avatar