Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 or 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 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 pts 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 characters. Submit for grading to confirm tests pass.
Ex: If input is:
Anna Bert
Sample output is:
Rounds must be
Rounds must be
Anna vs Bert for rounds
Step pts Use rand to generate random values for player followed by player 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 tests pass.
Ex: If input is:
Anna Bert
Sample output is:
Anna vs Bert for rounds
Tie
Tie
Step 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 tests pass.
Ex: If input is:
Anna Bert
Sample output is:
Anna vs Bert for rounds
Tie
Tie
Bert wins with scissors
Step pts Add a loop to repeat steps and 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:
Anna Bert
Sample output is:
Anna vs Bert for rounds
Anna wins with paper
Tie
Anna wins with rock
Anna wins with paper
Anna wins and Bert wins
THIS IS IN C CODE I NEED HELP FINISHING THE CODE BELOW
int main
const int ROCK ;
const int PAPER ;
const int SCISSORS ;
int seed;
scanfd &seed;
srandseed;
char player;
char player;
int rounds;
scanfs s d player player &rounds;
if rounds
printfRounds must be
;
while rounds
scanfd &rounds;
if rounds
printfRounds must be
;
printfs vs s for d rounds
player player rounds;
int pwins ;
int pwins ;
for int i ; i rounds; i
int pmove rand;
int pmove rand;
if pmove ROCK && pmove SCISSORS
printfs wins with rock
player;
pwins;
else if pmove SCISSORS && pmove PAPER
printfs wins with scissors
player;
pwins;
else if pmove PAPER && pmove ROCK
printfs wins with paper
player;
pwins;
else if pmove ROCK && pmove SCISSORS
printfs wins with rock
player;
pwins;
else if pmove SCISSORS && pmove PAPER
printfs wins with scissors
player;
pwins;
else if pmove PAPER && pmove ROCK
printfs wins with paper
player;
pwins;
else
printfTie
;
printfTie
;
if pwins pwins
printfs wins d and s wins
player pwins, player;
else if pwins pwins
printfs wins and s wins d
player player pwins;
else
printfBert wins with scissors";
return ;
Step 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