Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rules for rock, paper, scissors: rock beats scissors, paper beats rock, scissors

ID: 3643570 • Letter: R

Question

Rules for rock, paper, scissors: rock beats scissors, paper beats rock, scissors beats paper.
Write a while loop. Each time it runs, it asks player 1 to enter R, P, or S (for rock, paper or scissors), then asks player 2 the same thing. Declare a winner for the game and ask player 1 if she wants to play again. If input is Y, then run the loop again, else, exit the loop. After the loop, display how many games each player won and declare which player won the most games, or if it was a tie. Note: do not ask players for their names; simply refer to

Explanation / Answer

#include #include #include #include #include using namespace std; enum total { draw, win, loss }; const string str[6] = { "Rock", "Scissors", "Paper", " IT'S TIE!", " YOU WIN!", " YOU LOSE!" }; int main() { srand(time(0)); cout > input; int result, comp = rand() % 3; switch (input) { case 'r': case 'p': case 's': { int user = abs(input - 'r'); result = (2 * user + comp) % 3; scores[result]++; cout