I was told to write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program
should work as follows:
• When the program begins, a random number in the range of 1 through 3 is generated. (Don't display computer choice to the user yet).
o If the number is 1, then the computer has chosen rock.
o If the number is 2, then the computer has chosen paper.
o If the number is 3, then the computer has chosen scissors.
• The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. (Use menu if you prefer).
• At this point display computer's choice.
• Your program should chose the winner according to the following rules:
o "Rock smashes the scissors", so if one player chooses rock and the other player chooses
scissors, then rock wins and one point is awarded to the player who chose rock.
o "Scissors cut the paper", so if one player chooses scissors and the other player chooses
paper, scissors wins and one point is awarded to the player who chose scissors.
o "Paper wraps rock", so if one player chooses rock, and the other player chooses paper, paper
wins and one point is awarded to the player who chose paper.
o If both players make the same choice, then neither player gets a point.
Play the game until one player scores 10.
So basically I already have all the basics, but I'm completely lost and don't know how to loop it so it lets you play until one player scores 10 points.
int main()
{
//VARIABLES
int userChoice;
int compChoice;
int playerscore=0;
int computerscore=0;
...
while ((playerscore<=10) || (computerscore<=10)
{
Your code here
If not a tie, update score
}
...
if (playerscore==10)
{cout << "Player wins!" << endl;}
else
{cout << "Computer wins!" << endl;}