Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for Java. Although I solved this problem, I do not get points. what is t

ID: 3910534 • Letter: T

Question

This is for Java. Although I solved this problem, I do not get points. what is the problem?

Write a switch statement that checks nextChoice. If 0, print Rock If 1, print 'Paper". If 2, print "Scissors". For any other value, print Unknown. End with newline. Do not get input from the user, nextChoice is assigned in main0 1 import java.util.Scanner; 3 public class Roshambo 4 public static void main (String args) int nextChoice; nextChoice 2; switch(nextChoice) 10 t 12 case 0: 14 System.out.println("Rock");break; 16 case 1:System.out.println("Paper");break; 18 case 2:System.out.println("Scissors";break; 20 default:

Explanation / Answer

The output and code written by you are correct .You followed exactly what is mentioned in the program.There is no need to import scanner because we are not reading any input from user,nextChoice is given in the body of main () only.

And it is mentioned as End with new line. Which mean ' ' should be added for the output.

System.out.println("Rock")

System.out.println(" "); break;

and so on.

hope this will help.

Please comment for further queries.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote