Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are going to write a program to simulate the game of paper-rock-scissors. Th

ID: 3635142 • Letter: Y

Question

You are going to write a program to simulate the game of paper-rock-scissors.
The computer will play against a human in your program. This program will use no psychology or artificial intelligence. The computer will make its choice of paper ‘p’,
rock ‘r’ or scissors ‘s’ by generating a random number of 0, 1, or 2.

Write the program in this order:

First:

Write a function that will read in the user choice of ‘p’, ‘r’ or ‘s’ (upper or lower case). This function takes NO incoming parameters and returns a char, the user’s choice. They function will use a do-while loop that does not exit until the user enters in a valid choice.
Name this function readAndValidateUserMove

You can compile this code to make sure you have no syntax errors. Note, it will not link since you have not written main( ) yet.

Second:

Write a function that generates the computer move. This function has NO incoming parameters and returns the random computer choice. Generate a random number from 0 to 2. If the number is 0, the computer move to return is ‘p’, if the number is 1, the computer move to return is ‘r’ and if the number is 2, the computer move to return is ‘s’.

Compile this code. Note, it will not link since you have not written main( ) yet.

Third:

Write a function that takes in two parameters, the human move and the computer move. This function will compare the human move to the computer move and determine which won the hand. Return a value that can be checked in main( ) so main can print who won the hand.


Use these well-known rules:
paper beats rock
rock beats scissors
scissors beat paper
a tie is if neither wins (they both have the same choice)

Compile this code. Note, it will not link since you have not written main( ) yet.

Fourth:

Write main( ) using the requirements given below. Once this compiles, you can link and run and test the entire program.




main( )

Declare all the variables used in main.


Play the game of paper-rock-scissors. In main ask the user how many hands he/she wants to play. This must be an odd number, so you must validate this input to make sure the number is odd!

After each play, write a message stating who won the play like this:

Human won the play: paper beats rock

Computer won the play: scissors beats paper
-----------------------------------------------------

After each hand ( a hand is when one player wins the majority of the odd number.) For example if a round is 5 plays, the hand ends when either the computer or the human wins 3 plays. Print a message stating whether the computer won the hand or the human won the hand and print the current record like this:

Human: 3 wins Computer: 2 wins

Once either the computer or the human has won the majority of plays in the round, then print a good-bye message.

For example, if the user wants to play best of 5, then stop playing the hand when either the human or the computer wins 3 plays. Print a message stating who won the hand (round).

Explanation / Answer

#include #include #include using namespace std; int main() { srand((unsigned)time(0)); int choice; int compchoice = (rand()%2)+1; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote