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. 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 seed is read from input to initialize the random number generator. This supports automated testing and creates predictable results that would otherwise be random. Step 1 . Read two player names 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. Assume each player name contains less than 40 characters. Submit for grading to confirm 2 tests pass. Ex: If input is: 3 Anna Bert -3 -4 4 Sample output is: Rounds must be > 0 Rounds must be > 0 Anna vs Bert for 4 rounds Step 2 . Use rand() % 3 to generate random values (0 - 2) for player 1 followed by player 2. Continue to generate random values for both players until both values do not match. Output "Tie" when the values match. Submit for grading to confirm 3 tests pass. Ex: If input is: 10 Anna Bert 1 Sample output is: Anna vs Bert for 1 rounds Tie Tie Step 3 . 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. Ex: If input is: 39 Anna Bert 1 Sample output is: Anna vs Bert for 1 rounds Tie Tie Bert wins with scissors Step 4 . 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. Ex: If input is: 82 Anna Bert 3 Sample output is: Anna vs Bert for 3 rounds Anna wins with paper Tie Anna wins with rock Anna wins with paper Anna wins 3 and Bert wins 0 #include #include int main() { constint ROCK = 0; constint PAPER = 1; constint SCISSORS = 2; int seed; scanf("%d", &seed); srand(seed); /* Type your code here. */ return0; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question
use following code to solve the question 

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.

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 seed is read from input to initialize the random number generator. This supports automated testing and creates predictable results that would otherwise be random.

Step 1 . Read two player names 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. Assume each player name contains less than 40 characters. Submit for grading to confirm 2 tests pass.
Ex: If input is:

3 Anna Bert -3 -4 4

Sample output is:

Rounds must be > 0
Rounds must be > 0
Anna vs Bert for 4 rounds


Step 2 . Use rand() % 3 to generate random values (0 - 2) for player 1 followed by player 2. Continue to generate random values for both players until both values do not match. Output "Tie" when the values match. Submit for grading to confirm 3 tests pass.
Ex: If input is:

10 Anna Bert 1

Sample output is:

Anna vs Bert for 1 rounds
Tie
Tie


Step 3 . 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.
Ex: If input is:

39 Anna Bert 1

Sample output is:

Anna vs Bert for 1 rounds
Tie
Tie
Bert wins with scissors


Step 4 . 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.
Ex: If input is:

82 Anna Bert 3

Sample output is:

Anna vs Bert for 3 rounds
Anna wins with paper
Tie
Anna wins with rock
Anna wins with paper
Anna wins 3 and Bert wins 0
#include <stdlib.h>
#include <stdio.h>

int main() {
constint ROCK = 0;
constint PAPER = 1;
constint SCISSORS = 2;

int seed;
scanf("%d", &seed);
srand(seed);

/* Type your code here. */

return0;

}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage