Help! Java 18.2 practice Press 2 to customer support | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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