Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; int main() { cout cout cout cout cout cout cout const int ROCK = 0; const int PAPER = 1; const

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
#include
using namespace std;
int main() {
cout
cout
cout
cout
cout
cout
cout
const int ROCK = 0;
const int PAPER = 1;
const int SCISSORS = 2;
int seed;
cin >> seed;
srand(seed);
string player 1, string player 2
int rounds
cout
cout
cout
return 0;
}
C++ code please
5.17 LAB*: Rock paper scissors Program Specifications Write a program to play an automated game of Rock, Paper, Scissors. Two players make one of three hand signais at the same time. Hand signals represent a rock, a piece of paper, or a par 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 Faicon Computer) ... Note this program is designed foc 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 2 ( 2 pts). If the user is ready to play, the game will start. For this, generate random value ( 0 - 2) 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 Ealcon Computer vis Anna for 1 roundi Are you ready? [y]y Enter the hand signal (ROCK =0; PAPER =1; SCISSORS =2 ) : 1 Tie Enter the hand nignal (ROCK =0, RAPER - 1; SCISSORS - 2): 1 Tie Enter the hand signal (ROCK =0; PAPER =1, SCISSORS 2):1 Wrong hand aignal Enter the hand signal (ROCK =0 i PAPER =1+ SCISSORS =2):4 Wrong hand signal Enter the hand algnal (ROCK - 0, PAPER - 1, sCISSORS - 2) : 1 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 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; RAPER =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 by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions