Guys im new to programming and its really fun tbh but i'm having a hard time with my program could you guys help. Thanks!! :)
#include <iostream>
using namespace std;
int main()
{
char PX;
char PY;
cout<< "Welcome to my c++ Programming" <<endl;
cout<< "This program wil simulate Rock, Paper and Scissor Game" <<endl <<endl;
cout<< "If you press (r) or (R) it means you choose Rock." <<endl;
cout<< "If you press (p) or (P) it means you choose Paper." <<endl;
cout<< "If you press (s) or (S) it means you choose Scissor." <<endl <<endl;
cout<< "Player 1 Input your Choice" <<endl;
cin>>PX;
cout<< "Player 2 Input you Choice" <<endl;
cin>>PY;
if ("PX==R || PY==P")
{
cout<< "Player 2 Wins because Paper Covers Rock";
}
else if ("PX==P || PY==R")
{
cout<< "Player 1 Wins because Paper Covers Rock";
}
else if ("PX==R || PY==S")
{
cout<< "Player 1 Wins because Rock Breaks Scissors";
}
else if ("PX==S || PY==R")
{
cout<< "Player 2 Wins because Rock Breaks Scissors";
}
else if ("PX==P || PY==S")
{
cout<< "Player 2 Wins because Scissor cuts Paper";
}
else if ("PX==S || PY==P")
{
cout<< "Player 1 Wins because Scissor cuts Paper";
}
else
{
cout<< "Draw!";
}
return 0;
Please post all errors messages/compiler errors you get.
You have a couple of errors:
1) Your if statements are all strings for some reason, remove those quotes
2) You are trying to compare your PX/PY variables to a constant character like 'P', so you need to surround it in single quotes: if(PX == 'R')
Note single quotes ' are using for characters, and double quotes " are used for strings
3) Are you sure you want to be using || in your if statements? Try writing out the logical table for what PX and PY are and what the result of your statement is.