Project3 Java

0 comments

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:

page1image1212497344page1image1214398144

Deliverables:

Your .java file including:

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

  • The total reward that you receive (after playing the game 1000 times) as a comment on top of your Java code.
  • Introduction to Programming, Fall 2021 Project 3

    page2image1212731360

    Grading:

    1. Properlydefinetheloopforthegame(2points)
    2. Correctlydefinethestrategyforyourself(1.5points)
    3. Correctlydefinehowcomputerrandomlychoosesrock,paper,orscissors(1.5points)
    4. Calculatehowmanypointsyougainforeachoutcome(4points)
    5. Proper display of output and comments where necessary (1 point)

    About the Author

    Follow me


    {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}