Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java Programming, Thank you. Question 1: Write a program that lets the user to play the game of Rock, Paper, Scissors against the computer.
In Java Programming, Thank you.
Question 1: 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 compChoice to generate and return a random integer number in the range of 1 through 3. The method also displays the computer's 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. Input validation is required. 3. Write a method named checkWinner to check and display the winner. The method accepts two integer arguments (one argument for computer's 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 quitStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started