Hello, I need some help with this program of c++ here is the link https://sites.
ID: 3744361 • Letter: H
Question
Hello, I need some help with this program of c++ here is the link
https://sites.google.com/site/uiccs141/programs/prog-1-dice I am done till the step 3 of this program and need help with step 4 to do a loop to produce the output 50 times.
Here is my program that produces the output one time.
#include <iostream>
#include <cstdlib> // Needed for rand() to work
using namespace std;
int main()
{
cout << "Class: CS 141" << endl;
cout << "System: C++ in codio.com" << endl;
cout << "Welcome to the dice game, where you and your opponent each choose" <<endl;
cout << "one of the red, green or blue dice and roll them." <<endl;
cout << "The dice contain the following sides:" << endl;
cout << " Red: 1 4 4 4 4 4" << endl;
cout << " Green: 2 2 2 5 5 5" << endl;
cout << " Blue: 6 3 3 3 3 3" << endl;
int red[] = {1,4,4,4,4,4};
int green[] = {2,2,2,5,5,5};
int blue[] = {6,3,3,3,3,3};
int player1Score=0,player2Score=0;
char player1Color,player2Color;
cout<<"Enter the die colors (R G or B): " << endl;
cin>>player1Color>>player2Color;
int player1Value=0,player2Value=0;
int randomNumber1,randomNumber2;
randomNumber1=(rand()%6);
randomNumber2=(rand()%6);
if(player1Color=='R')
player1Value=red[randomNumber1];
else if(player1Color=='G')
player1Value=green[randomNumber1];
else if(player1Color=='B')
player1Value=blue[randomNumber1];
if(player2Color=='R')
player2Value=red[randomNumber2];
else if(player2Color=='G')
player2Value=green[randomNumber2];
else if(player2Color=='B')
player2Value=blue[randomNumber2];
if(player1Value>player2Value)
player1Score++;
else if(player1Value==player2Value){
}
else{
player2Score++;
}
cout<<player1Color<<":"<<player1Value<<" "<<player2Color<<":"<<player2Value << ",";
cout<<" Score: "<<player1Score<<" to "<<player2Score<<endl;
return 0;
}//end main()
I need help with the 4th step to do a loop and run the dice 50 times.
I would really appreciate if you could help me with the last step, Thank you.
Explanation / Answer
#include #include // Needed for rand() to work using namespace std; int main() { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.