Back to DFS's Pascal Page


Dice Rolls Graph Problem II

The first dice rolls problem taught you several things. Among them were how to draw a bar graph and that with a relatively small number of trials statistical fluctuation can creep into the results. In this problem you will increase the number of trials more than a hundredfold.

The task is, on the surface, very similar to the one you performed before. However, there is a major complication: with 36,000 rolls, you will not be able to use an asterisk to represent each instance of each sum. You are to have the program calculate a ratio (multiplier) to use to scale down the graph so that it fits on the screen. This would allow you to change the number of rolls without having to manually change the ratio.

Furthermore, the solution you were forced to use prohibited the use of arrays. This caused your code to be much longer than it needed to be. This time you must use an array to keep track of the frequencies of the various possible sums.

Sample results of rolling two dice 36000 times are as follows.

 2s: ***********                                                          1010
 3s: *********************                                                1979
 4s: ********************************                                     2972
 5s: *******************************************                          4011
 6s: *****************************************************                4958
 7s: *****************************************************************    6071
 8s: ******************************************************               5003
 9s: *******************************************                          4029
10s: ********************************                                     2978
11s: *********************                                                1987
12s: ***********                                                          1002

Pseudocode

The structure of your program should be very simple.

  1. Setup
  2. Roll dice 36000 times and count how many times each sum comes up
  3. Determine the scaling ratio based on the greatest frequency in your array
  4. Report results

© DFStermole 2008
Created 30 Mar 08
Modified 1 Apr 08