I'm running this code in Visual C++ 6.0 and it won't run correctly.. need some expert help..
I don't know what's wrong with this code..
Thanks for the help in advance..
# include <iostream>
using namespace std;
int main()
{
char one, two, answer;
do {
system("cls");
cout<<"\n\n\t\tSelect a key from the following choices:";
cout<<"\n\n\t\t\tKey:\t\tMeaning:";
cout<<"\n\n\t\t\t P\t\t paper";
cout<<"\n\t\t\t R\t\t rock";
cout<<"\n\t\t\t S\t\t scissor";
cout<<"\n\nEnter player 1:";
cin>>one;
cout<<"Enter player 2:";
cin>>two;
if (one=='P'||'p' && two=='P'||'p')
{
cout<<"\nResult: Tie!\nNobody wins!";
}
else if (one=='R'||'r' && two=='R'||'r')
{
cout<<"\nResult: Tie! \nNobody wins!";
}
else if (one=='S'||'s' && two=='S'||'s')
{
cout<<"\n Result: Tie! \nNobody wins!";
}
else if (one=='P'||'p' && two=='R'||'r')
{
cout<<"\n\nResult: Player 1 wins! \n Basis: Paper Covers Rock!";
}
else if (one=='R'||'r' && two=='S'||'s')
{
cout<<"\nResult: Player 1 wins! \n Basis: Rock Breaks Scissor!";
}
else if (one=='S'||'s' && two=='P'||'p')
{
cout<<"\nResult: Player 1 wins! \n Basis: Scissor Cuts Paper!";
}
else if (one=='R'||'r' && two=='P'||'p')
{
cout<<"\n\nResult: Player 2 wins! \n Basis: Paper Covers Rock!";
}
else if (one=='S'||'s' && two=='R'||'r')
{
cout<<"\nResult: Player 2 wins! \n Basis: Rock Breaks Scissor!";
}
else if (one=='P'||'p' && two=='S'||'s')
{
cout<<"\nResult: Player 2 wins! \n Basis: Scissor Cuts Paper!";
}
else
{
cout<<"Wrong output!";
}
cout<<"\t\n\n\nWould you like to play again? y/n:";
cin>>answer;
}
while (answer=='Y'||'y');
return 0;
}
I also tried this but the result is the same..
Where did i go wrong?
Help please..
# include <iostream>
using namespace std;
main()
{
char one, two, answer;
do {
system("cls");
cout<<"\n\n\t\tSelect a key from the following choices:";
cout<<"\n\n\t\t\tKey:\t\tMeaning:";
cout<<"\n\n\t\t\t P\t\t paper";
cout<<"\n\t\t\t R\t\t rock";
cout<<"\n\t\t\t S\t\t scissor";
cout<<"\n\nEnter player 1:";
cin>>one;
cout<<"Enter player 2:";
cin>>two;
if (one=='P'||one=='p' && two=='P'||two=='p')
{
cout<<"\nResult: Tie!\nNobody wins!";
}
else if (one=='R'||one=='r' && two=='R'||two=='r')
{
cout<<"\nResult: Tie! \nNobody wins!";
}
else if (one=='S'||one=='s' && two=='S'||two=='s')
{
cout<<"\n Result: Tie! \nNobody wins!";
}
else if (one=='P'||one=='p' && two=='R'||two=='r')
{
cout<<"\n\nResult: Player 1 wins! \n Basis: Paper Covers Rock!";
}
else if (one=='R'||one=='r' && two=='S'||two=='s')
{
cout<<"\nResult: Player 1 wins! \n Basis: Rock Breaks Scissor!";
}
else if (one=='S'||one=='s' && two=='P'||two=='p')
{
cout<<"\nResult: Player 1 wins! \n Basis: Scissor Cuts Paper!";
}
else if (one=='R'||one=='r' && two=='P'||two=='p')
{
cout<<"\n\nResult: Player 2 wins! \n Basis: Paper Covers Rock!";
}
else if (one=='S'||one=='s' && two=='R'||two=='r')
{
cout<<"\nResult: Player 2 wins! \n Basis: Rock Breaks Scissor!";
}
else if (one=='P'||one=='p' && two=='S'||two=='s')
{
cout<<"\nResult: Player 2 wins! \n Basis: Scissor Cuts Paper!";
}
else
{
cout<<"Wrong output!";
}
cout<<"\t\n\n\nWould you like to play again? y/n:";
cin>>answer;
}
while (answer=='Y'||answer'y');
return 0;
}