Using nextint() during switch statements

Let’s give the user the ability to choose a menu option. Recall that we will use the scanner object to get user input. Use the scanner object’s nextInt() method to get the user’s choice and make sure to save it into a variable named choice

    String choice = sc.nextInt();
    switch(choice) {
  case 1: System.out.println("Here is your steak!");
          break;
  case 2: System.out.println("Here is your wings!");
          break;
  case 3: System.out.println("Here is your salad!");
          break;
  default: System.out.println("You want nothing?!");
          break;

I’ve tried String, Char, etc. and still can’t move pass this step.

It looks like you are missing a closing } for your switch statement.

import java.util.Scanner;

class Main {
public static void main(String args) {
Scanner sc = new Scanner(System.in);
System.out.println(“\nWelcome to our Diner! Please select an entree:\n”
+ “1) steak\n”
+ “2) wings\n”
+ “3) salad\n”
+ “and any other number for nothing!”);
String choice = sc.nextInt();
switch(choice) {
case 1: System.out.println(“Here is your steak!”);
break;
case 2: System.out.println(“Here is your wings!”);
break;
case 3: System.out.println(“Here is your salad!”);
break;
default: System.out.println(“You want nothing?!”);
break;
}
}
}

Hi @PerryChapman can you please link to your Repl for this.

The solution relates to your chosen data type for capturing the choice variable in String choice = sc.nextInt(); but I’d like to see the Replit to make sure.