Question: Write a java program that plays the game Rock-Paper-Scissors. (Scissors cut paper; rock breaks scissors; paper covers rock.) The user will play against the computer.

Write a java program that plays the game Rock-Paper-Scissors. (Scissors cut paper; rock breaks scissors; paper covers rock.) The user will play against the computer. Scissors cut paper, rock breaks scissors, paper covers rock.

For the computers selection, the program will randomly generate a number 0, 1, or 2 representing rock, paper, or scissors. The program promts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws.

Sample run:

Rock (0), Paper (1), Scissors (2): 0 Enter The computer is scissors. You are rock. You win.

Rock (0), Paper (1), Scissors (2): 1 Enter The computer is paper. You are paper. It is a draw.

Analysis Input: You need to know which number the user wants. Use the secure random number generator to come up with a number for the computer.

Processing: Compare the users number and the computers number and see who wins. Translate the users and computers numeric choices into words.

Output: Display the computers choice. Display the users choice. Display the outcome.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a Java program that plays the RockPaperScissors game we will follow these steps Step 1 Set Up the Program Import Required Classes Import jav... View full answer

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!