I CAN'T... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I CAN'T...

import java.util.Scanner; class Demo { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int number; do { number = scanner.nextInt(); switch (number) { case 1: System.out.println("Language selection"); break; case 2: System.out.println("Customer support"); break; case 3: System.out.println("Check account balance"); break; case 0: System.out.println("Exit"); break; } } while (number != 0); } } IT GIVES ME ERROR...

2nd Mar 2024, 10:28 PM
Ivan Lazzaro
5 Answers
+ 6
in Sololearn you have to put all your inputs in the popup box. Your code needs to have a final input of 0 to exit properly, so your input would have to be something like 1 5 3 2 0 submit <-- click submit button
2nd Mar 2024, 10:59 PM
Bob_Li
Bob_Li - avatar
+ 2
What error does it give you? Maybe we can help you more easily if you attach your code as per this guide: https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app
2nd Mar 2024, 10:53 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
You are getting input in a infinite loop, put number = scanner.nextInt(); out of the loop, and add more operations inside the while, like while(number < 0 || number > 3); https://sololearn.com/compiler-playground/cVT6B4oRq7m6/?ref=app
3rd Mar 2024, 11:45 PM
Andres Gómez
Andres Gómez - avatar
+ 1
Ya this is runned before any write the no..
3rd Mar 2024, 6:02 PM
Varsha Bhidwadiya
Varsha Bhidwadiya - avatar
0
So hard
3rd Mar 2024, 9:04 PM
Tosin Shodipe