Question: Play the rock paper scissors game. Two players enter either rock , paper , or scissors and the winner is determined as follows: paper covers

Play the rock paper scissors game. Two players enter either rock, paper, or scissors and the winner is determined as follows:

paper covers rock rock breaks scissors scissors cut paper. 

Ask the user if s/he wants to play again. BE SURE to include a function called play as shown in the template.

Sample run:

Play rock, paper, scissors Player 1: rock Player 2: paper Player 2 wins -- Paper covers rock Do you want to continue? (yes or no): yes Player 1: scissors Player 2: rock Player 2 wins -- Rock breaks scissors Do you want to continue? (yes or no): no 

#include

#include

using namespace std;

/* Type your code here. */

int main()

{

string p1, p2;

cout << "Play rock, paper, scissors ";

string goOn = "yes";

while (goOn == "yes") {

cout << "Player 1: ";

cin >> p1;

cout << p1 << endl;

cout << "Player 2: ";

cin >> p2;

cout << p2 << endl;

int winner = play(p1, p2);

if (winner == 0)

cout << "Draw!" << endl;

else if (winner == 1)

cout << "Player 1 wins!" << endl;

else if (winner == 2)

cout << "Player 2 wins!" << endl;

else

cout << "ACK! SOMETHING IS WRONG!" << endl;

cout << "Do you want to continue? (yes or no): ";

cin >> goOn;

cout << goOn << endl;

}

}

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!