I am doing an assignment and I need some pointers on how to roll a die a total of 5000 times. I am not sure what to do next to make the die table work! Here is my code so far:
[php]
<?php $faceside1 = 1; $faceside2 = 2; $faceside3 = 3; $faceside4 = 4; $faceside5 = 5; $faceside6 = 6; //Frequency of Die $frequency1 = 1; $frequency2 = 2; $frequency3 = 3; $frequency4 = 4; $frequency5 = 5; $frequency6 = 6; $face = rand(1, 6); switch ($face) { case "1": echo $frequency1++; break; case "2": echo $frequency2++; break; case "3": echo $frequency3++; break; case "4": echo $frequency4++; break; case "5": echo $frequency5++; break; case "6": echo $frequency6++; break; default : echo "0"; } ?> <html>
<head>
<meta charset="UTF-8">
<title>Statistical analysis of results from rolling a six‐sided die</title>
</head>
<body>
<h2 style="text-align:center">Statistical analysis of results from rolling a
six‐sided die</h2>
<table width='600' border='1' cellspacing='0' cellpadding='5' align='center'>
<tr>
<th>Face</th>
<th>Frequency</th>
</tr>
<?php
define("MAXIMUM_TOTAL", 6);
for ($frequencytotal = 1; $frequencytotal <= MAXIMUM_TOTAL; $frequencytotal++) {
$faceside = ${'faceside' . $frequencytotal};
$frequency = ${'frequency' . $frequencytotal};
echo "<tr>
<td> $faceside </td>
<td> $frequency </td>
</tr>";
}
?>
</body>
[/php]
I am not sure where to add the frequency of 5000 and I am having the random number in the top left corner on the webpage as well. I have all the numbers in the table tho, but I am stuck right now on what I should change or do next. We have not learned arrays yet, so that is something I cannot add! Any help is greatly appreciated!