Question: Write a program that simulates the rolling of a die 6000 times and displays in a table format the number of occurrences of each side
Write a program that simulates the rolling of a die 6000 times and displays
in a table format the number of occurrences of each side of the die.
Note: die (referring to the small cube used in games of chance) is singular for the
plural dice.
In order to shed a bit more light on the required method of tallying the
6000 values into tally_array (as described in a comment in the
random_die_rolls_start.cpp above), here is an example of the first few iteration
of the loop:
At the beginning, the tally_array should contain 7 zeros:
0 0 0 0 0 0 0
and let's say that the first five num_array elements from the die throws contain these
values:
2 4 6 2 2 ...
In the loop the first element '2' would point to the third element (index 2) in
tally_array to access it - then, increment it. Now, tally_array looks like this:
0 0 1 0 0 0 0
By the time the loop runs through the first five elements of the 6000 rolls,
tally_array will look like this:
0 0 3 0 1 0 1
Makes sense? You must understand this before going any further.
The start file already contains code to help debug important variable
contents. Leave those in for the final output and add to it if necessary.
These debug statements are there to encourage the student to adopt similar
systems in order to understand what the program is doing and check code.
display the results ruffly in this format, the main thing being that Occurrences' are
right alined.
Display Result for 6000 Rolls
Die Face Occurrences
===========================
1 1013
2 972
3 963
4 1018
5 975
6 1059
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
