Organize the lines of code to create a switch statement that checks nextChoice.

Check the final answer first, then review the worked steps.

Answer

switch (nextChoice) { case 0: System.out.println("Rock"); break; case 1: System.out.println("Paper"); break; case 2: System.out.println("Scissors"); break; default: System.out.println("Unknown"); }

Approach

switch (nextChoice) { case 0: System.out.println("Rock"); break; case 1: System.out.println("Paper"); break; case 2: System.out.println("Scissors"); break; default: System.out.println("Unknown"); }

Step-by-step solution

  1. Start the switch statement with switch (nextChoice) {.
  2. Handle case 0: by printing "Rock" and adding a break;.
  3. Handle case 1: by printing "Paper" and adding a break;.
  4. Handle case 2: by printing "Scissors" and adding a break;.
  5. Add a default: case to print "Unknown".
  6. Close the switch block with }.