0

Help! Java 18.2 practice Press 2 to customer support

They don't work. Donno why. import java.util.Scanner; public class Main {    public static void main(String[] args) {        Scanner scanner = new Scanner(System.in);        int number = scanner.nextInt;        do {        Switch(number){            case 1 :            System.out.println("Language selection");            number = scanner.nextInt;            break;                       case 2 : System.out.println("Customer support");            number = scanner.nextInt;            break;             case 3 :             System.out.println("Check the balance");             number = scanner.nextInt;             break;                         case 4 :             System.out.println("Check loan balance");             number = scanner.nextInt;             break;        }                }        while(number != 0);    }    System.out.println("Exit") }

31st Jul 2021, 7:18 AM
Jungi Lee
Jungi Lee - avatar
4 Réponses
+ 5
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int number; do { //take input and output corresponding message /* 1 => Language selection 2 => Customer support 3 => Check the balance 4 => Check loan balance 0 => Exit */ number = scanner.nextInt(); switch (number) { case 0: System.out.println("Exit"); break; case 1: System.out.println("Language selection"); break; case 2: System.out.println("Customer support"); break; case 3: System.out.println("Check the balance"); break; case 4: System.out.println("Check loan balance"); break; } } while(number != 0); } }
31st Jul 2021, 7:55 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Check out some of the existing threads on the Java 18.2 practice. You look pretty close! https://www.sololearn.com/discuss/2765373/?ref=app https://www.sololearn.com/discuss/2664100/?ref=app
31st Jul 2021, 7:26 AM
Hatsy Rei
Hatsy Rei - avatar
0
I checked out, but it didn't help :(
31st Jul 2021, 7:42 AM
Jungi Lee
Jungi Lee - avatar
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int number = scanner.nextInt(); do { switch (number) { case 1: System.out.println("Language selection"); number = scanner.nextInt(); break; case 2: System.out.println("Customer support"); number = scanner.nextInt(); break; case 3: System.out.println("Check the balance"); number = scanner.nextInt(); break; case 4: System.out.println("Check loan balance"); number = scanner.nextInt(); break; } } while(number == 1 || number == 2 || number == 3 || number == 4); System.out.println ("Exit"); } }
25th Nov 2021, 8:46 PM
Daniel Snyman