elseif ((a=='r') && (b=='p') || (a=='s') && (b=='r') || (a=='p') && (b=='s') ) This should be elseif ((a=='r' && b=='p') || (a=='s' && b=='r') || (a=='p' && b=='s') ) The first one needs to be similar also. Btw you could just do an else for the tie.
To make the logic easier, convert the user's input to lower (or upper) case. You'll also want to validate it as others have said. You could put all this in a function:
1 2 3 4 5
bool normalize(char &c)
{
c = tolower(c);
return c == 'r' || c == 'p' || c == 's';
}
You might also put the logic for a winner into a function:
1 2 3 4 5 6
// Return true if FIRST beats SECOND. Both parameters must be normalized
// (i.e., either 'r', 'p' or 's')
firstIsWinner(char first, char second)
{
return first=='p' && second=='r' || first=='r' && second=='s' || first=='s' && second=='p';
}
Now your main logic gets easier and your code can double check itself:
if ((a=='r'||a=='R') && (b=='r'||b=='R') || (a=='p'||a=='P') && (b=='p'||b=='P') || (a=='s'||a=='S') && (b=='s'||b=='S') )
{
cout<<"\n\n\n\n\n\n\n\n\n\n\n "<<PLAYER_1<<" and "<<PLAYER_2<<" TIE!";
}
there are much better ways to check if it is a tie. Such as if neither player won then it is a tie. Or something like if(a == b) or better yet if(toupper(a) == toupper(b))
Technically speaking logic error shouldn't be within the game conditions. That should be checked while you get the input. I think I also mentioned the else on my earlier post. http://www.cplusplus.com/forum/beginner/141476/#msg747290