Question: Write a program that lets the user to play the game of Rock, Paper, Scissors against the computer. In the program, 1 means rock, 2

Write a program that lets the user to play the game of Rock, Paper, Scissors against the computer.

In the program, 1 means rock, 2 means paper, 3 means scissors.

The program should work as follows:

1. Write a method named computerChoice to generate and return a random integer number in the range of 1 through 3. The method also displays the computers choice. if the random number is 1, display rock. if the random number is 2, display paper. if the random number is 3, display scissors.

2. Write a method named userChoice to return the user's choice (an integer). The user enters his or her choice of "rock", "paper", "scissors" at the keyboard. The method then use a decision structure to decide the corresponding number (1 means rock, 2 means paper, 3 means scissors) and return that number.

3. Write a method named checkWinner to check and display the winner. The method accepts two integer arguments (one argument for computers choice, the other argument for user's choice). A winner is selected according to the following rules:

rock smashes scissors. Rock wins

Scissors cuts paper. Scissor wins

Paper wraps rocks. Paper wins

If the same, it is a tie

4. In the main method: call the above methods in proper order to play the game. After each round, ask the user if she/he wants to play again. Play the game until the user says no or quit.

Requirements:

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!