Introduction to Programming, Fall 2021 Project 3 Maximum points: 10 Due: 1:00 pm on November 3rd, 2021
Project 3: 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 scissors (usually with an outstretched hand). The rule of the game is simple: rock crushes scissors, scissors 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-scissors game against the computer for 1000 times. You receive the
following rewards each time you play the game:
- You get $2 if you win
- Youget$1ifthereisatie
- You get $0 if you loseThe computer randomly chooses rock, paper, or scissors in each game. Rather than deciding what to play (rock, paper or scissors) for each individual game, you decide to use the following strategy:
- Play rock for games 1-300
- Play scissors for games 301-600
- Play paper for games 601-1000Write 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.Hint:Use loops to simulate the game 1000 times. In each iteration, generate a random integer 1, 2, or 3 representing rock, paper, and scissors, 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:
Deliverables:
Your .java file including:
int randomNum = 1 + (int)(3*Math.random( ));
Introduction to Programming, Fall 2021 Project 3
Grading:
- Properlydefinetheloopforthegame(2points)
- Correctlydefinethestrategyforyourself(1.5points)
- Correctlydefinehowcomputerrandomlychoosesrock,paper,orscissors(1.5points)
- Calculatehowmanypointsyougainforeachoutcome(4points)
- Proper display of output and comments where necessary (1 point)


0 comments