I need help!

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.


THIS IS WHAT I GOT!
-------------------

#include <iostream>
#include <ctime>
#include <stdlib.h>


using namespace std;

void displayMenu();

int main()
{
//VARIABLES
int userChoice;
int compChoice;

srand(time(0));
compChoice = rand() % 3 + 1;
//MENU

displayMenu();
cin >> userChoice;

if(userChoice == 1)
cout << "You selected: Rock " << endl;
else if(userChoice == 2)
cout << "You selected: Paper " << endl;
else if(userChoice == 3)
cout << "You selected: Scissors " << endl;



//COMPUTER CHOICE
if(compChoice == 1)
cout << "The computer has selected Rock " << endl;
else if(compChoice == 2)
cout << "The computer has selected Paper " << endl;
else if(compChoice == 3)
cout << "The computer has selected Scissors " << endl;



//INSTANCES
if (userChoice == 1 && compChoice == 1)
cout << "Tie!" << endl;
else if (userChoice == 1 && compChoice == 2)
cout << "Paper wraps rock" << endl;
else if (userChoice == 1 && compChoice == 3)
cout << "Rock smashes the scissors" << endl;


else if (userChoice == 2 && compChoice == 1)
cout << "Paper wraps rock" << endl;
else if (userChoice == 2 && compChoice == 2)
cout << "Tie" << endl;
else if (userChoice == 2 && compChoice == 3)
cout << "Scissors cut the paper" << endl;


else if (userChoice == 3 && compChoice == 1)
cout << "Rock smashes the scissors" << endl;
else if (userChoice == 3 && compChoice == 2)
cout << "Scissors cut the paper" << endl;
else if (userChoice == 3 && compChoice == 3)
cout << "Tie" << endl;



return 0;
}

void displayMenu()
{
cout << "Game Menu!" << endl;
cout << "----------" << endl;
cout << "1> Rock" << endl;
cout << "2> Paper" << endl;
cout << "3> Scissors" << endl;
cout << "4> Enter your choice: ";
}


-----------------------------------------

THIS IS WHAT THE PROG IS SUPPOSED TO LOOK LIKE!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;}
Last edited on
Topic archived. No new replies allowed.