Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ C++ Program Specifications Write a program to play an automated game of Rock, Paper, Scissors. Two players make one of three hand signals at
C++
C++
Program Specifications Write a program to play an automated game of Rock, Paper, Scissors. Two players make one of three hand signals at the same time. Hand signals represent a rock, a piece of paper, or a pair of scissors. Each combination results in a win for one of the players. Rock crushes scissors, paper covers rock, and scissors cut paper. A tie occurs if both players make the same signal. Use a random number generator of 0,1 , or 2 to represent the three signals for the first player (The Falcon Computer).... Note: this program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. Step 0. Read starter template and do not change the provided code. Integer constants are defined for ROCK, PAPER, and SCISSORS. A Random object is created and a seed is read from input and passed to the Random object. This supports automated testing and creates predictable results that would otherwise be random. Step 1 (2 pts). Read one player name from input (string). Read number of rounds from input. Continue reading number of rounds if value is below one and provide an error message. Output player names and number of rounds (player 1: The Falcon Computer, player 2: User). If the user it is no ready to start the game, output Game over message. Submit for grading to confirm 2 tests pass. Sample run (Interleaved input / output): Step 4 (3 pts). Add a loop to repeat steps 2 and 3 for the number of rounds. Output total wins for each player after all rounds are complete. Submit for grading to confirm all tests pass. Sample run (Interleaved input / output): Enter the random() seed: 82 Enter your name: Anna Enter the number of rounds: 3 The Falcon Computer vs Anna for 3 rounds Are you ready? [y] y Enter the hand signal (ROCK =0; PAPER =1;SCISSORS=2 ): 3 Wrong hand signal Enter the hand signal (ROCK =0;PAPER=1;SCISSORS=2 ): 1 Tie Enter the hand signal (ROCK =0; PAPER =1;SCISSORS=2 ): 0 Tie Enter the hand signal (ROCK =0; PAPER =1;SCISSORS=2 ): 1 Anna wins with paper Enter the hand signal (ROCK =0; PAPER =1;SCISSORS=2 ): 2 The Falcon Computer wins with rock Enter the hand signal (ROCK =0;PAPER=1;SCISSORS=2 ): 1 Anna wins with paper The Falcon Computer wins 1 and Anna wins 2 Step 3 (3 pts). Identify winner for this round and output a message. Rock crushes scissors, scissors cut paper, and paper covers rock. Submit for grading to confirm 6 tests pass. Sample run (Interleaved input / output): Enter the random() seed: 39 Enter your name: Anna Enter the number of rounds: 1 The Falcon Computer vs Anna for 1 rounds Are you ready?[y] y Enter the hand signal (ROCK =0; PAPER =1; SCISSORS =2 ): 1 Tie Enter the hand signal (ROCK =0; PAPER =1; SCISSORS =2 ): 1 Tie Enter the hand signal (ROCK =0; PAPER =1;SCISSORS=2 ) 0 The Falcon Computer wins with paper The Falcon Computer wins 1 and Anna wins 0 Step 2 (2 pts). If the user is ready to play, the game will start. For this, generate random value (02) for player 1 (computer) by calling rand () \% 3. Followed by a message prompting the user to enter the hand signal, and if the hand signal is invalid provide an error message and ask for a new input until a valid input is entered. Continue to generate random values for player 1 and ask the user to input values until both values do not match. Output "Tie" when the values match. Submit for grading to confirm 3 tests pass. Sample run (Interleaved input / output): Enter the random() seed: 10 Enter your name: Anna. Enter the number of rounds: 1 The Falcon Computer vs Anna for 1 rounds Are you ready? [y] y Enter the hand signal (ROCK =0; PAPER =1;SCISSORS=2 ): 1 Tie Enter the hand signal (ROCK =0;PAPER=1;SCISSORS=2 ): 1 Tie Enter the hand signal (ROCK =0; PAPER =1;SCISSORS=2 ): 1 Wrong hand signal Enter the hand signal (ROCK =0;PAPER=1;SCISSORS=2 ): 4 Wrong hand signal Enter the hand signal (ROCK =0;PAPER=1;SCISSORS=2 ): 1Step 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