Paper, Rock, Scissors help

Hello,
I'm new to C++ and struggling with my homework.
I have to make a paper, rock, scissors game with functions. Here is the specifics of the assignment:

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 choserock.
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.
Be sure to divide the program into functions that perform each major task. Also, pass data by value, by
reference, and/or use static variables and named constants.


here is my code...any help will be greatly appreciated.
Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include <stdlib.h>
#include <string>


using namespace std;

int main()
{
    string userAnswer;
    string finalAnswer;
    string num1 = "Rock";
    string num2 = "Paper";
    string num3 = "Scissors";
    int compNumber;
    int userScore = 0;
    int compScore = 0;  
    do
    {

        cout << "Game Menu" << endl;

        for(int i=0; i<20; i++)
        {cout<< "-";}
         cout<< endl;

        cout<< "1) Rock" << endl;
        cout<< "2) Paper" << endl;
        cout<< "3) Scissors" << endl;
        cout<< "Enter Your choice:" << endl;
        int userAnswer;
        cin >> userAnswer;

{//inner loop
for (int i=0; i<5; i++)

compNumber = rand ()%3+1;
if (compNumber == 1)
{
    cout <<"The Computer selected: Rock";
    cout << endl;
}
else if (compNumber ==2)
{
    cout << "The Computer selected: Paper";
    cout << endl;
}
else if (compNumber == 3)
{
    cout << "The Computer selected:  Scissors";
    cout << endl;
}

if (userAnswer == 1)
{
    cout << "You selected: Rock";
    cout << endl;
}
else if (userAnswer == 2)
{
    cout << "You selected: Paper";
    cout << endl;
}
else if (userAnswer == 3)
{
    cout << "You selected: Scissors";
    cout << endl;
}
if (num1 > num3 && compNumber !== num1)
{
    cout << "YOU WIN!  Rock smashes the scissors";
    cout << endl;
    userScore++;
}
else if (num3 > num2 && compNumber !== num3)
{
    cout << "YOU WIN!  Scissors cut the paper" ;
    cout << endl;
    userScore++;
}
else if (num2 > num1 && compNumber !== num2)
{
    cout << "YOU WIN!  Paper wraps rock";
    cout << endl;
    userScore ++;
}

}

cout << "USER SCORE" <<  ":" << "COMPUTER SCORE" << endl;
cout << userScore <<     ":"  << compScore << endl;
cout << "Would you like to try again? <Y/N>>:";
 cin >> finalAnswer;

}//outer loop end
while (finalAnswer == "Y/N" || finalAnswer == "y/n");





    return 0;
}
What part(s) are you struggling with?
how do I turn what i've written, into functions?

is my point scoring system correct?

is the overall logic correct?
I am new too but you may need to seed use the srand function?
Topic archived. No new replies allowed.