Question: in java RPS.java Load default template... m public class RPS { in public static void main(String[] args) { 9 } 20.5 a2, #2 Rock-paper-scissor Write

in java RPS.java Load default template... m public class RPS { inpublic static void main(String[] args) { 9 } 20.5 a2, #2 Rock-paper-scissorin java

RPS.java Load default template... m public class RPS { in public static void main(String[] args) { 9 } 20.5 a2, #2 Rock-paper-scissor Write a program that allows a user to play a single game of rock-paper-scissor against the computer. Prompt the user to enter a random number seed and 'R', 'P', or 'S', then generate a random play for the computer, and finally announce the winner. When announcing the winner, be sure to state what the computer played, and the basis for winning: rock breaks scissors, paper covers rock, scissors cuts paper, or tie (nobody wins). Use a series of if-else statements to determine the winner. You should allow the user to enter lowercase or uppercase letters. If an invalid play is entered, print an error message and stop. To determine what the computer plays, generate a random number using the java.util.Random package and map these numbers to R-P-S. This will require creating a new instance of the Random class, setting the seed, and then calling the nextInt method: Random rndm = new Random(); rndm.setSeed (seed); // where 'seed' is the value you read from the input You may use the above code without attribution. See the documentation for Random.nextInt(). https://docs.oracle.com/javase/8/docs/api/java/util/Random.html. To get more practice with different branching constructs, use a switch statement to convert your random number to 'R', 'P', or 'S'. When the input field is: 200 R The output should be: Enter a seed number and R, P, or s: You entered: R The computer played: S You win! Rock breaks scissors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!