+ 1
Donde está el error
Pro algún motivo nunca imprime la primera opción y si la primera opción es 0 tira un error. No entiendo que está mal https://code.sololearn.com/c16h0Q0A3bJ4/?ref=app
6 Antworten
+ 1
You input variable number only once. If it is 0 your program will end otherwise it will loop forever.
+ 1
Like this it works, please look at the comments for what i changed:
import java.util.Scanner;
public class Main {
public static int numero ; // added global var numero
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// removed input
//tu código va aquí
// removed if statement
do {
numero = scanner.nextInt(); // removed int
if (numero == 1){
System.out.println("Language selection");
} if (numero == 2){
System.out.println("Customer support");
} if (numero == 3){
System.out.println("Check the balance");
} if (numero == 4){
System.out.println("Check the loan balance");
} if (numero == 0){
System.out.println("Exit");
}
} while (numero != 0); // changed number to nunero
}
}
+ 1
The input at sololearn is odd, you have to give all your input on separate lines before you push submit:
https://code.sololearn.com/cRzePwPL5oY8/?ref=app
0
thanks a lot!
0
I have tried the code you wrote but it seems it doesnt work. Could you post a link to where I can run it and chek it? Thanks again
0
it works great! thanks a lot. I am just beggining at programming so I get confused many times. Thanks for your help