I need help figuring out how to do this lab This is the skel

I need help figuring out how to do this lab. This is the skeleton I must fill in. Code should be in C++

Thankyou!

Include //Include library necessary for rand function using namespace std; int main() {srand(3333);//Do not change the seed value.//TODO: Declare all necessary variables int numRolls; int scores cout

Solution

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
   srand(3333);

   int numRolls;
   int scores,total=0;
   int count[12] = {0};

   cout<<\"Enter number of times you want to roll a pair of dice: \";
   cin>>numRolls;
   cout<<endl;

   for(int i=0;i<numRolls;i++)
   {
       scores = (rand() % 6 + 1) + (rand() % 6 + 1);
       count[scores-1]++;      
   }

   cout<<endl;
   cout<< \"# of times each score was rolled\" <<endl;

   for(int i=1;i<12;i++)
   {
       cout<<i+1<<\": \"<<count[i]<<endl;
       total = total + count[i];
   }

   cout<<endl;
   cout<< \"Probability of rolling each possible score\" <<endl;
   cout<<total<<endl;
   for(int i=1;i<12;i++)
   {
       cout<<i+1<<\": \"<<((double)count[i]*100)/total<<\"%\"<<endl;
   }  

   return 0;
}

I need help figuring out how to do this lab. This is the skeleton I must fill in. Code should be in C++ Thankyou! Include //Include library necessary for rand f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site