Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions: Declare your variables: Declare two int variables, playerchoice and computerchoice. The player's choice will be input by the user, and the computer's choice will
Instructions:
Declare your variables: Declare two int variables, playerchoice and computerchoice. The player's choice will be input by the user, and the computer's choice will be preset in the program.
Prompt for user input: Use cout to prompt the player to enter a number between and for Rock, for Paper, and for Scissors Use cin to store the player's choice in playerchoice.
Set the computer's choice: Set computerchoice to a constant value between and This will be the computer's move in the game.
Implement your control structures:
Use switch statements to translate playerchoice and computerchoice from numbers to their corresponding strings Rock Paper, Scissors and display them using cout.
Create an if statement that checks for a tie ie playerchoice is equal to computerchoice If it's a tie, print a message indicating this.
Create an else if statement for each possible win scenario Rock beats Scissors, Scissors beat Paper, Paper beats Rock If the player wins, print a message congratulating them.
Create an else statement for the scenarios where the player does not win. If the code reaches this point, it means the player did not tie or win, so they must have lost. In this case, print a message indicating that the player lost.
Test your program: Compile and run your program. Test it with all possible player choices to ensure all scenarios are handled correctly.
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