I've tried different ways of laying out my if statements, I even tried nested if statements. I get the same result. I'm not sure of any way to ask my question besides showing my code.
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int main()
{
char playerOne, playerTwo;
cout<<"ROCK PAPER SCISSORS!"<<endl;
cout<<"Enter P for Paper"<<endl;
cout<<"Enter R for Rock"<<endl;
cout<<"Enter S for Scissors"<<endl;
cout<<"Player One enter your choice: ";
cin>>playerOne;
cout<<"Player Two enter your choice: ";
cin>>playerTwo;
if ((playerOne = 'R') && (playerTwo = 'R'))
cout<<"Both players played same hand";
else if ((playerOne = 'R') && (playerTwo = 'P'))
cout<<"Player Two wins!";
else if ((playerOne = 'R') && (playerTwo = 'S'))
cout<<"Player One wins!";
else if ((playerOne = 'P') && (playerTwo = 'R'))
cout<<"Player One wins!";
else if ((playerOne = 'P') && (playerTwo = 'P'))
cout<<"Both players played same hand";
else if ((playerOne = 'P') && (playerTwo = 'S'))
cout<<"Player Two wins!";
else if ((playerOne = 'S') && (playerTwo = 'R'))
cout<<"Player Two wins!";
else if ((playerOne = 'S') && (playerTwo = 'P'))
cout<<"Player One wins!";
else if ((playerOne = 'S') && (playerTwo = 'S'))
cout<<"Both players played same hand";
else
cout<<"Invalid inputs!";
getche();
return 0;
}
you need the double == sign instead of =
== can be read as "is equal to"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With