Question: I need help with a rock, paper, and scissor program in C++ language. Here is the question: Write a program to score the paper-rock-scissor game.

I need help with a rock, paper, and scissor program in C++ language.

Here is the question:

Write a program to score the paper-rock-scissor game. Each of the two users types in ether P, R, or S. The program then announces the winner as well as the basis for determining the winner: Paper covers rock, Rock brakes scissors, Scissors cut paper, or Nobody wins. Be sure to allow the users to use lowercase as well as uppercase letters. Your program should include a loop that lets the user play again until the user says she or he is done.

Here is my code:

#include using namespace std;

int main( ) { // Variables declaration. char user1; char user2; char choice; // Repeat the loop until the player exits the game. do { // Prompt user 1 to enter their choice. cout << "Enter either P)aper, R)ock, or S)cissors for player number 1: "; cin >> user1; // Prompt user 2 to enter thier choice. cout << "Enter either P)aper, R)ock, or S)cissors for player number 2: "; cin >> user2; // Display an error message if any of the users enters an invalid choice. // Verify whether the choices entered by the players are valid. if(user1 != 'P' && user1 != 'p' && user1 != 'R' && user1 != 'r' && user1 != 'S' && user1 != 's' && user2 != 'P' && user2 != 'p' && user2 != 'R' && user2 != 'r' && user2 != 'S' && user2 != 's') { // Print an error message. cout << "Invalid choice!" << endl; } // Verify whether the player 1 choose the papper. else if(user1 == 'P' || user1 == 'p') { // Verify whether the player 2 chooses the rock. if(user2 == 'R' || user2 == 'r'); { cout << "Paper covers rock." << endl; cout << "User 1 wins the game." << endl; } // Verify whether the player 2 chooses the scissors. else if(user2 == 'S' || user2 == 's') { cout << "Scissors cut paper." << endl; cout << "Player 2 wins the game." << endl; } // If both the plyers choose paper. else { cout << "Nobody wins the game." << endl; } } // Verify whether the player 1 choose rock. else if(user1 == 'R' || user1 == 'r') { // Verify whether play 2 chooses the scissors. if(user2 == 'S' || user2 == 's') { cout << "Rock breaks scissors." << endl; cout << "Player 1 wins the game." << endl; } // Verify wether player 2 chooses the paper. else if(user2 == 'P' || user2 == 'p') { cout << "Paper covers rock." << endl; cout << "Player 2 wins the game." << endl; } // If both players choose rock. else { cout << "Nobody wins the game." << endl; } } // If the player 1 chooses the scissors else if(user1 == 'S' || user1 == 's') { // Verify whether player 2 chooses the paper. if(user2 == 'P' || user2 == 'p') { cout << "Scissors cut paper." << endl; cout << "Player 1 wins the game." << endl; } // Verify whether the user 2 choose the rock. else if(user2 == 'R' || user2 == 'r') { cout << "Rock breaks scissors." << endl; cout << "Player 2 wins the game." << endl; } // If both players choose scissors. else { cout << "Nobody wins the game." << endl; } } // Prompt the player's choice to play the game agian. cout << "Enter Y/y to play game again: "; cin >> choice; cout << endl; }while(choice == 'Y' || choice == 'y'); // Pause the system for a while system("pause"); return0; }

Can anybody tell me what I am doing worng?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!