I'm tasked to simulate the roll of two dice, generate two random integers between 1 & 6 inclusive, add them together, and use that minus two to index an array to accumulate the count of how many time each result occurred for 10,000 rolls of the two dice.
The problem is that in main() you pass the array dice with only zeros to printArrays and also value is 0. Should roll() receive an array to fill? What is the meaning of value it returns?
roll is supposed to roll two dice randomly and give a value.
int main or roll whichever would be better should roll 10000 different sets and give how many of each value (2-12) come up, how many were expected to come up, and percentage of error.
It is output to value, Acutal and percent but it is outputting the wrong values. the Value column should be dice options (2-12) Actual Count should how many times each got rolled within 10,000 rolls. Expected and percent should be based on the odds. Please Help!
One problem is initializing and filling the array in main() int dice[12] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
All values should be 0 and you also need only 11 elements.
Try your loop like this:
1 2 3 4 5
for (int value = 0; value < 10000; value++)
{
rolls = roll();
dice[rolls - 2]++;
}
Why do you pass the result from the last throw to printArrays() ? printArrays(cout, dice, rolls);