Hi guys what is wrong in my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi guys what is wrong in my code?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner read = new Scanner(System.in); int password; do{ System.out.println("Write password"); password=read.nextInt; password++; } while(password!=8819); } }

17th Jan 2023, 8:32 AM
Zaki Hakimi
Zaki Hakimi - avatar
1 Answer
+ 1
Incorrect lines are : password=read.nextInt; //missing () Must be like password=read.nextInt(); // this increments input value, why you need it? // for example, if input is 8819 then increment cause it to 8820 password++; I think task is to accept input until correct password entered then just accept input and remove incrementation....
17th Jan 2023, 9:39 AM
Jayakrishna 🇮🇳