I am having problem in this code please someone solve this I have tried so many times to solve this but failed. | Sololearn: Learn to code for FREE!

+1

I am having problem in this code please someone solve this I have tried so many times to solve this but failed.

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.nextlnt(); } while(password != 8819); } } Find the error solve it and let me know about the fault I was making.

8/11/2022 3:29:26 AM

Priyanshu Singh

10 Answers

New Answer

+3

Awesome when I make mistakes It still helps! Now that's motivation. 😂 But because of that I will test my solution 3x over before I submit anything else. Thanks for being so kind😃

+2

Priyanshu Singh your code is almost identical to mine with the exception in the do section I have those lines reversed as .. do { password = read.nextInt(); System.out.println("Write password"); } while (password != 8819); } } When I used your code it passed

+2

Sorry Priyanshu Singh it was my app showing the inserted characters. It used to be a problem for others. But in this case it wasn't a problem for you. I thought I deleted my statements before you read them.

+2

there is typo in .nextlnt(); because low L has similar visual as big I

+2

zemiak that is a capital i not l as in l-ike but i- as in ike

+2

Those (upper-case I and lower-case L) can be tricky 😅

+1

Thanks BroFar for your help. But It was a given program by this app. So I couldn't change those lines. That's why I tried nextShort instead of nextlnt. Thanks again BroFar.

+1

0

Chris Coder thanks for your help man, But it was a mistake I was giving nextlnt() instead of nextShort() and because of that it was showing error. Thanks again man for reply.

0

Its Ok Brother. No problem. I am thankful that you replied to my comment and that gave me motivation to read those lessons again. Because of that I find out which mistake I was making. Thanks Man. Don't be sorry.