Need help on Rock Paper Scissors game

So I got an assignment to make a rock paper scissors game using c++. I know there is something in my code that isn't correct because the outcome is always the first output of each case in my switch statement.

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
#include <iostream>
using namespace std;

int main ()
{
	char user1, user2;
	cout << "input a letter";
	cin >> user1;
	cout << "input a second";
	cin >> user2;

	switch (user1)
	{
	case 'r': case 'R':
		if (user2 == 'r'||'R')
			cout << "its a tie";
		
		else if (user2 == 'p' || 'P')
			cout << "user 2 won";

		else if (user2 == 'S' || 's')
			cout << "user 1 wins";
		break;

	case 'P': case 'p':
		if (user2 == 'r'||'R')
			cout << "User 1 wins";
		
		else if (user2 == 'p' || 'P')
			cout << "It's a tie";
		
		else if (user2 == 'S' || 's')
			cout << "user 2 wins";
		break;
	case 'S': case 's':
		if (user2 == 'r'||'R')
			cout << "user 2 won";
		
		else if (user2 == 'p' || 'P')
			cout << "user 1 won";
		
		else if (user2 == 'S' || 's')
			cout << "It's a tie";
		break;
	}
	

	 system("pause");
	 return 0; 
}
  

Help would be much appreciated :]
enclose the statements for each case in a bracket

1
2
3
4
5
6
7
8
9
10
case 'S': case 's':
		if (user2 == 'r'||'R')
			cout << "user 2 won";
		
		else if (user2 == 'p' || 'P')
			cout << "user 1 won";
		
		else if (user2 == 'S' || 's')
			cout << "It's a tie";
		break;


to
1
2
3
4
5
6
7
8
9
10
11
12
13
case 'S': case 's':
         {
		if (user2 == 'r'||'R')
			cout << "user 2 won";
		
		else if (user2 == 'p' || 'P')
			cout << "user 1 won";
		
		else if (user2 == 'S' || 's')
			cout << "It's a tie";
		break;
          }



also for clarity:
 
if (user2 == 'r' || user2 == 'R') 
Last edited on
Topic archived. No new replies allowed.