- #1
sandy.bridge
- 798
- 1
Homework Statement
I'm writing a program for a game similar to rock-paper-scissors. It is called proton-neutron-electron (P, N, E). There are two players. In the event of a tie, player 2 wins
P1 denotes player 1, P2 denotes player 2, P = proton, N = neutron, E = electron. P1P means player 1 picks proton.
There are 9 possibilities. Here they are:
P1P + P2P = P2 wins
P1P + P2N = P1 wins
P1P + P2E = P1 wins
P1N + P2P = P2 wins
P1N + P2N = P2 wins
P1N + P2E = P2 wins
P1E + P2P = P1 wins
P1E + P2N = P2 wins
P1E + P2E = P2 wins
The Attempt at a Solution
Here is what I have written in the compiler; it does not work. I am not looking for another solution, I would just like to know where I went wrong in my syntax.
PHP:
char user1, user2;
bool A, B, C, D, E, F;
cout << "Player 1, please enter your move: ";
cin >> user1;
cout << "Player 2, please enter your move: ";
cin >> user2;
if (user2 = 'P')
{
A = true;
}
else
{
A = false;
}
if (user2 = 'N')
{
B = true;
}
else
{
B = false;
}
if (user2 = 'E')
{
C = true;
}
else
{
C = false;
}
if (user1 = 'P')
{
D = true;
}
else
{
D = false;
}
if (user1 = 'N')
{
E = true;
}
else
{
E = false;
}
if (user1 = 'E')
{
F = true;
}
else
{
F = false;
} if ((B&&D)||(C&&D)||(A&&E)||(B&&F))
{
cout << "The winner is player 1!";
}
else
{
cout << "The winner is player 2!";
}
return 0;
Last edited: