Write Switch Statement Checks Nextchoice 0 Print Rock 1 Print Paper 2 Print Scissors Va Q37049724

Write a switch statement that checks nextChoice. If 0, print”Rock”. If 1, print “Paper”. If 2, print “Scissors”. For any othervalue, print “Unknown”. End with newline. Do not get input from theuser; nextChoice is assigned in main().

code Given:

import java.util.Scanner;

public class Roshambo {
public static void main (String [] args) {
int nextChoice;

nextChoice = 2;

/* Your solution goes here */

}
}


Solution


public class Roshambo { public static void main(String args[]){ int nextChoice; nextChoice = 2; switch (nextChoice){

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.