Back to DFS's Workshop Page
Back to Agenda Page


Tabulating Dice Rolls II

For this problem, you are to cannibalize any available code and write a pair of scripts which will do the following.

  1. The HTML Page: nsideddicerolls.html
  2. The PHP Script: nsideddicetable.php
    1. Check the data received to ensure that the value is possible; use die or exit to report problems and terminate execution
    2. Tell the user how many rolls were requested
    3. Simulate the rolling of the dice using the rand function (see also Generating Random Values), storing the values in a pair of arrays
    4. Calculate the sum of each roll of the pair of dice, storing the results in an array
    5. Calculate the means for the rolls of each die and for the sums of each pair
    6. Print a table which specifies six things:
      1. Labels for the columns
      2. The number of the roll in the first column
      3. The first die in the second column
      4. The second die in the third column
      5. The sum of the dice in the fourth column
      6. The means of the second, third, and fourth columns in the last row

To see how this should work, view this possible solution.

Notes


© 2006 DFStermole
Created 19 Oct 06
Last Modified 8 Nov 07