Question
C++ don't forget THIS IS THE CODE FOR LAB 3 BELOW!!!!! /* The purpose of this lab is to create a program that takes the
C++ don't forget
THIS IS THE CODE FOR LAB 3 BELOW!!!!!
/* The purpose of this lab is to create a program that takes the input of R, S or P
from the user and compares it to the random choice from the computer to see who wins. */
#include
#include
#include
#include
using namespace std;
int main()
{
double Rock, Paper, Scissors;
char userChoice, compChoice;
srand (time(0));
cout
cin >>userChoice;
int num = rand() %3+1;
switch(num)
{
case 1: compChoice = 'R';
break;
case 2: compChoice = 'S';
break;
case 3: compChoice = 'P';
break;
}
if(compChoice == userChoice)
cout
else if (userChoice == 'R')
{if (userChoice == 'P')
cout
else
cout
}
else if (userChoice == 'P')
{if (compChoice == 'R')
cout
else
cout
}
else if (userChoice == 'S')
{if (compChoice == 'P')
cout
else
cout
}
cout
cout
cout
return 0;
}
Lab 4 - Add Loops to Lab 3 Objectives: Make use of a for loop and Make use of a while loop and Make use of a do-while loop Instructions: Part A: Add a for loop to run the Rock, Paper, Scissors program n times and print how many times you won, how many times the computer won and how many times ended in a tie. Input n from the user as 5 or above. Part B: Add a while loop to the Rock, Paper, Scissors program to keep running until you have won n times. Input n from the user. Print how many times you won, how many times the computer won and how many times ended in a tie. Read in n from the user as 5 or above. Part C: Add a do while loop to the Rock, Paper, Scissors program to keep running the program until the user says to stop. At the end of the program print how many times you won, how many times the computer won and how many times ended in a tie. Run at least 5 times. Run: Run the first version, second version and third version. Make sure you have not created an endless loop when you run the programStep 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