Question
C++ Please read directions, Write a program that lets the user play the game Rock, Paper, Scissors against the computer. 1.When the program begins, a
Write a program that lets the user play the game Rock, Paper, Scissors against the computer.
1.When the program begins, a random number in the range of 1 -3 is generated. If the number is 1, then the computer has chosen rock. 2 corresponds to paper, and 3 corresponds to scissors.
2.The user chooses rock, paper, or scissors. Use a menu with an input validation loop that maps 1 - 3 to rock, paper, scissors, and 4 to exit.
3. Start a while loop to allow the user to repeat the game or exit.
4. The player's choice is displayed.
5.The computer's choice is displayed.
6.A winner is selected using the following rules: Rock beats scissors. Scissors beats paper. Paper beats rock. If both players make the same choice, it is a tie.
7. Generate a new computer choice, asks the user for a new menu choice, and loop to play a new game if they didn't select 4 to exit.
Use the following function prototypes in your design:
// Function Prototypes int getUserChoice(); //print menu to ask user choice and return as int int getComputerChoice(); //generate random computer choice and return as int void determineWinner(int, int); //compare the two choices and print the winner (or tie) void displayChoice(int); //Print rock, paper, or scissors depending on the int parameter. Use to print the player or the computer's choice.
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