Question: Write a program to score the paper-rock-scissor game. Each of two users types in either P, R, or S. The program then announces the winner
Write a program to score the paper-rock-scissor game. Each of two users types in either P, R, or S. The program then announces the winner as well as the basis for determining the winner: Paper covers rock Rock breaks scissors Scissors cut paper 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 users play again until they say they are done.
#include <iostream>
using namespace std;
int main()
{
// Variable declaration
char Player1, Player2, ans;
//setting the stage
cout << "Rock/Paper/scissors is a simple game. The rules are: \n Rock beats scissors. \n Scissors beats Paper. \n Paper beats rock.\n";
cout << "This is a two person game, choose wisely and no cheating \n";
cout << "Enter R for rock, P for paper, S for scissor, or Q to give up \n";
cout << "Player1 declar your weapon of choice." << endl;
cin >> Player1;
cout << "Player2 declar your weapon of choice" << endl;
cin >> Player2;
cout << "ROCK, PAPER, SCISSOR.. SHOOT!" << endl;
do
{
if ((Player1 = ('R' || 'r')) && (Player2 = ('S' || 's')))
{
(cout << " Player1 wins, Rock beats scissors \n ");
}
else if ((Player1 = ('S' || 's')) && (Player2 = ('R' || 'r')))
{
(cout << "Player2 wins, Rock beats scissors \n ");
}
else if ((Player1 = ('P' || 'p')) && (Player2 = ('R' || 'r')))
{
(cout << "Player1 wins, Paper covers rock \n ");
}
else if ((Player1 = ('R' || 'r')) && (Player2 = ('P' || 'p')))
{
(cout << "Player2 wins, Paper covers rock \n ");
}
else if ((Player1 = ('S' || 's')) && (Player2 = ('P' || 'p')))
{
(cout << "Player1 wins, Scissors cuts paper \n ");
}
else if ((Player1 = ('P' || 'p')) && (Player2 = ('S' || 's')))
{
(cout << "Player2 wins, Scissors cuts paper \n ");
}
else if ((Player1 = (('R' || 'r') || ('S' || 's') || ('P' || 'p'))) = ((Player2 = (('R' || 'r') || ('S' || 's') || ('P' || 'p')))));
{
cout << "It's a Draw! No one wins!\n";
}
cout << "Do you want to play again? Press 'Y' for yes or 'N' for no\n";
cin >> ans;
} while (ans == 'Y' || ans == 'y');
cout << "Thanks for playing " << endl;
return 0;Step by Step Solution
3.40 Rating (172 Votes )
There are 3 Steps involved in it
It seems the question is complete but the provided code has several errors and logical issues that need addressing to function correctly Lets break do... View full answer
Get step-by-step solutions from verified subject matter experts
