Hello,
I just joined this web site and i'm new to programming and i'm stuck on this program, can't seem to finish it, after couple of days of trying to figure this program out, i realize i need help.
The program is pretty much done i just don't know where to put the default for player one. I have it for player two, but not for one. Greatly appreciated if someone could help.
Thank you.
#include <iostream>
using namespace std;
int main()
{
char playerOne;
char playerTwo;
//Display player's choices
cout << "Welcome to the rock-paper-scissors game.\n" ;
cout << "Player 1 please enter your move: ('R' for rock,";
cout << "'P' for paper, and 'S' for scissors)" << endl;
cin >> playerOne;
cout << "Welcome to the rock-paper-scissors game.\n" ;
cout << "Player 2 please enter your move: ('R' for rock,";
cout << "'P' for paper, and 'S' for scissors)" << endl;
cin >> playerTwo;
// Using the switch statement and switch statement
if(playerOne == 'S' || playerOne == 's'){
switch(playerTwo){
case 's':
case 'S': cout << "Tie with Scissors!" << endl;
break;
case 'r':
case 'R': cout << "Player 2 Wins: Rock breaks Scissors!" << endl;
break;
case 'p':
case 'P': cout << "Player 1 wins: Scissors cut Paper!!" << endl;
break;
}
}
else if (playerOne == 'R' || playerOne == 'r'){
switch(playerTwo){
case 'r':
case 'R': cout << "Tie with Rock!" << endl;
break;
case 'p':
case 'P': cout << "Player 2 Wins: Paper covers Rock!" << endl;
break;
case 's':
case 'S': cout << "Player 1 wins: Rock breaks Scissors!" << endl;
break;
}
}
else
{
switch(playerTwo){
case 'p':
case 'P': cout << "Tie with Paper!" << endl;
break;
case 's':
case 'S': cout << "Player 2 Wins: Scissors cut Paper!" << endl;
break;
case 'r':
case 'R': cout << "Player 1 wins: Paper covers Rock!!" << endl;
break;
default: cout << "player 2 has entered an invalid move." << endl;
break;
}
}
return 0;
}