Question: java Write a program that will play the game rock-paper-scissors with the computer. The user will enter a number representing their choice: 1 = rock

java
java Write a program that will play the game rock-paper-scissors with the

Write a program that will play the game rock-paper-scissors with the computer. The user will enter a number representing their choice: 1 = rock paper 3 = scissors The computer will then generate a random number between 1-3 and determine who wins the game. Here are the rules for the game: User 1 = rock 1 = rock Computer 1 = rock 2 = paper Winner Tie Computer (Paper covers Rock) User (Rock crushes Scissors) User (Paper covers Rock) 1 = rock 3 = scissors 2 = paper 2 = paper 2 = paper 1 = rock 2 - paper 3 = scissors Tie 3 = scissors I rock Computer (Scissors cut Paper) Computer (Rock Crushes Scissors) User (Scissors cut Paper) Tie 3 - scissors 3 = scissors 2 - paper 3 - scissors The user should be asked if they want to play again, program should continue until the user enters "no". The following code generates a random number between 1 and 3 to be used to determine the computer's selection. import java.util.; import java.util.Random; public class choiceGen public static void main(String U args) { Scanner K = new Scanner (system.in); Random rand = new Random(); int n = rand.nextInt(3) + 1

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!