Question: C++ Programming ONLY please. Fill in the missing code BELOW where it says student provides missing code The program output will look this after complete.

C++ Programming ONLY please.

Fill in the missing code BELOW where it says "student provides missing code"

The program output will look this after complete. Please upload screenshot with how it looks compiled along with the source code.

C++ Programming ONLY please. Fill in the missing code BELOW where it

Problem

Allow the user to specify the number-of-sides of a die, S, the number-of-dice, D, and the number-of-trials, T. Because there is no requirement to validate user input, you may safely assume

(1 S 11), (1 D 11), and (T 1)

By definition, a trial consists of repeatedly throwing the D Ssided dice until all the dice thrown show exactly the same face. For example, for S = 6 and D = 2, 1 trial might require the 8 throws (1,6) (2,3) (1,4) (5,6) (2,5) (4,6) (3,4) and finally (2,2).

After all trials have been run, display 1 line which shows the minimum number-of-throws used for a trial, the maximum number-of-throws used for a trial, and the average of the number-of-throws used for all trials using the format shown below. Note#1 The average is the real number which is computed as the quotient of the sum of number-of-throws for all trials (numerator) and the number-of-trials (denominator).

111111111122222222223333333333444444444455555555

123456789012345678901234567890123456789012345678901234567

Minimum XXXXXXXXXX, maximum XXXXXXXXXX, average XXXXXXXX.X

Note #2 Your Monte Carlo simulation is attempting to show the average number-of-throws required for D S-sided dice is SD/S = SD-1, the number predicted by the theory of the geometric distribution which is implicit in the dice-throwing experiment.

#include

#include

#include

#include

using namespace std;

//--------------------------------------------------

void SetRandomSeed(void)

//--------------------------------------------------

{

srand( (unsigned int) time(NULL) );

}

//--------------------------------------------------

double RandomReal(void)

//--------------------------------------------------

{

double r;

int i;

i = rand();

// i is in [ 0,RAND_MAX ]

if ( i == 0 )

r = 0.0;

else

r = (double) (i-1)/RAND_MAX;

// r is in [ 0.0,1.0 )

return( r );

}

//--------------------------------------------------

int RandomInteger(int LB,int UB)

//--------------------------------------------------

{

double RandomReal(void);

return( (int) (RandomReal()*(UB-LB+1)) + LB );

}

//--------------------------------------------------

bool RandomBoolean(double bias)

//--------------------------------------------------

{

double RandomReal();

return( RandomReal()

}

//--------------------------------------------------

char RandomCharacter(char characters[],int size)

//--------------------------------------------------

{

int RandomInteger(int LB,int UB);

return( characters[RandomInteger(0,(size-1))] );

}

//--------------------------------------------------

int main()

//--------------------------------------------------

{

void RunOneTrial(int S,int D,int &throws);

int S,D;

int T,minimum,maximum,throws,sum;

cout > S;

cout > D;

cout > T;

SetRandomSeed();

Student provides missing code to run T trials to determine and subsequently display

the minimum, maximum, and average = sum/T of number-of-throws required for the T trials.

system("PAUSE");

return( 0 );

}

//--------------------------------------------------

void RunOneTrial(int S,int D,int &throws)

//--------------------------------------------------

{

bool AllDieTheSame(int die[],int D);

int *die = new int [ D ];

Student provides missing code to run one trial, counting the number-of-throws

of the D S-sided dice required before all die faces are the same.

delete [] die;

}

//--------------------------------------------------

bool AllDieTheSame(int die[],int D)

//--------------------------------------------------

{

Student provides missing code to implement the quantification

AllDieTheSame = "i (die[i] = die[i+1]), i [ 0,D-2 ]

...or equivalently

AllDieTheSame = (die[0] = die[1]) && (die[1] = die[2]) && ... && (die[D-2] = die[D-1])

}

Sample Program Dialog S? 6 D? 5 T? 10000 Minimum L, maximum 11784, average 1290.2 S? 10 D? 2 T? 10000 Minimum (6) 5-1 = 1296 1, maximum 96, average 9.9 (10)2-1 = 10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!