Is the random interger new Random?

Is the random interger new Random?

Should the statement look like-

switch (new Random)

case r:

break;

case p:

break;

case s;

break;

default:

import java.util.Scanner;

import java.util.Random;

public class Rock

{

public static void main(String[] args){

String personPlay; //User’s play — “R”, “P”, or “S”

String computerPlay; //Computer’s play — “R”, “P”, or “S”

int computerInt; //Randomly generated number used to determine computer’s play

Random generator = new Random();

Scanner scan = new Scanner (System.in);

//Get player’s play — note that this is stored as a string

System.out.print (“Enter your play: R, P, or S: “);

personPlay = scan.nextLine();

//Make player’s play uppercase for ease of comparison

personPlay = personPlay.toUpperCase();

//Generate computer’s play (0,1,2)

computerInt = generator.nextInt(3);

//Translate computer’s randomly generated play to string

//”R”, “P”, or “S”. If play is not a value you expected (0,1,2),

//set it to “I” and print a warning message.

// WRITE A SWITCH STATEMENT THAT USES THE RANDOM INTEGER

// GENERATED IN computerInt TO ASIGN computerPlay THE LETTERS “R”, “P”,

// “S”

// MAKE THE DEFAULT OF THE SWITCH STATEMENT ASIGN computerPlay THE LETTER “I”

// AND PRINT AN UNEXPEXTED RANDOM NUMBER MESSAGE TO THE CONSOLE

//Print computer’s play

System.out.println(“Computer play is ” + computerPlay);

// USING AN ELSE IF CLAUSE, PRINT AN “Illegal person play” MESSAGE TO CONSOLE IF

// personPlay IS NOT A “P”, “R”, OR “S”

// ELSE IF computerPlay IS AN “I” PRINT AN “Illegal computer play” MESSAGE TO CONSOLE

// OTHERWISE, DECIDE WHO WON (HINT USE NESTED IFS), REMEMBER:

// ROCK BEATS SCISSOR

// SCISSOR BEATS PAPER

// PAPER BEATS ROCK

}

}

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?