Question: Program: Rock-Paper-Scissors Game Description: The popular rock-paper-scissors game is usually played between two people in which each player simultaneously chooses either a rock or a

Program: Rock-Paper-Scissors Game Description: The popular rock-paper-scissors game is usually played between two people in which each player simultaneously chooses either a rock or a paper or a scissor (usually with an outstretched hand). The rule of the game is simple: rock crushes scissor, scissor cuts paper, and paper wraps rock. If both the players choose the same object, then it ends in a tie. (See this link for more details.) Problem Description: You have to play the rock-paper-scissor game against the computer for 1000 times. You receive the following rewards each time you play the game:

You get $2 if you win

You get $1 if there is a tie

You get $0 if you lose

The computer randomly chooses rock, paper, or scissor in each game. Rather than deciding what to play (rock, paper or scissor) for each individual game, you decide to use the following strategy:

Play rock for games 1-300

Play scissor for games 301-600

Play paper for games 601-1000

Write a program to play the rock-paper-scissors game against the computer for 1000 times using the above strategy. You are required to calculate the total reward that you accumulate after playing the game 1000 times.

Use loops to simulate the game 1000 times. In each iteration, generate a random integer 1, 2, or 3 representing rock, paper, and scissor, respectively and use that number to know what computer has played. Using your strategy described above, figure out whether you win, lose or tie the game in each iteration. Maintain a variable to keep a track of the amount that you have won and keep updating that amount in each iteration depending on the result of the game. You can generate a random integer 1, 2, or 3 as follows:

int randomNum = 1 + (int)(3*Math.random( ));

***Also, please display code using Java

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!