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

Using switches and for loops Appropriate constants and enums. No literals, excep

ID: 3640168 • Letter: U

Question

Using switches and for loops

Appropriate constants and enums.

No literals, except to define a const or enum.

Write a Rock, Paper, Scissors simulator, asking the user for the number of games they want to play, play that number of games with the user, and print summary statistics for the session.

Should display the strategy the user picks, and the strategy the computer is playing, before announcing the result of the game.

Simulation must be able to randomly choose a strategy (one of the three plays).

Summary of statistics should include:
• Number of wins per side
• Number of ties
• Number of wins per strategy

Explanation / Answer

#include<iostream>
using namespace std;
int main()
{
char a,b;
cout<<" For Paper click P For Rock click R For Scissors click S ";
cout<<"Player 1: ";
cin>>a;
cout<<"Player 2: ";
cin>>b;
if ((a=='r' || a=='R') && (b=='s' || b=='S'))
cout<<" Rock breaks scissors Player 1 wins! ";
else if ((a=='r' || a=='R') && (b=='p' || b=='P'))
cout<<" Paper covers rock Player 2 wins! ";
else if ((a=='r' || a=='R') && (b=='r' || b=='R'))
cout<<"It's a tie! ";
else if ((a=='p' || a=='P') && (b=='s' || b=='S'))
cout<<" Scissors cut paper Player 2 wins! ";
else if ((a=='p' || a=='P') && (b=='r' || b=='R'))
cout<<" Paper covers rock Player 1 wins! ";
else if ((a=='P' || a=='P') && (b=='p' || b=='P'))
cout<<"It's a tie! ";
else if ((a=='s' || a=='S') && (b=='P' || b=='p'))
cout<<" Scissors cut paper Player 1 wins! ";
else if ((a=='s' || a=='S') && (b=='R' || b=='r'))
cout<<" Rock breaks scissors Player 2 wins! ";
else if ((a=='s' || a=='S') && (b=='s' || b=='S'))
cout<<"It's a tie! ";
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote