Question
This is a C++ question need to complete project 2. attached the completed simple version of the program below but need the updated version which
This is a C++ question need to complete project 2. attached the completed simple version of the program below but need the updated version which is listed in the project 2 outline
Project 2
Rock, Paper, Scissors Updated
Take the solution to Lab 3 and make sure the user enters a letter of R, P, or S and the computer generates a number between 0-2 and changes that number to a letter of R, P or S, using a switch. Make sure the user knows why he/she has won or lost print a message like Paper covers Rock or Scissors cuts Paper.
Ask the user how many times he/she wants to play and incorporate that into a for loop or allow the user to keep playing until he/she says to stop using a do-while loop.
Add the code to count how many wins, losses and ties that the user has and print the results at the end of the program before stopping the program.
Allow the user to exit a game, not the program, if he wants to use a code of X. Also keep a count of exits from a game. Make sure your run has at least one exit.
Also have the program determine if a user did not type in R, P, S or X and print Bad Code and allow the user to continue the game. Run at least once with a Bad Code.
using namespace std;
#include
int main() { //Declaration statements srand(time(0)); char user, computer; int comp=rand()%3+1; if (comp==1) computer='R'; else if(comp==2) computer='P'; else computer='S';
//Input Statements cout<<"Type in your choice (R,P,S) "; cin>>user; cout<<"user has picked "< //Output statements if(user==computer) cout<<"Tie"< //else user rock else if(user=='R') if (computer=='P') cout<<"computer-wins-Paper crushes Rock"< //else//user is paper else if(user=='P') if (computer=='R') cout<<"you win-paper crushes Rock"< //Final statements return 0;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started