Jump to content

Gaomon

New Members
  • Posts

    7
  • Joined

  • Last visited

Gaomon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I know I lack common sense, but when you are not taught something that is needed for your project and you really don't know how to do something and are asking for help, that is a different story. I went to the school tutor for help and he taught me how to do it by giving me an example and it was nothing like what was taught in class, so I just couldn't get it. I got everything in class til now, but I couldn't get this. Again, I am a student and I am still learning!
  2. Um... I am only taking this class, because I am required to. I am a video major, not a coding major, so I am sorry I am new to PHP!
  3. Nope, never learned how to do pseudocode, so it wouldn't have worked for me! It's all good. I got it worked out!
  4. I actually had to go to the tutor at school, since I couldn't get any help. I had him explain it, since some of the code we never used or put together, like the rand($min, $max) with a for loop, so having me writing out the code in pseudocode wouldn't have worked! Also, I had the Switch conditional function having echos, which made a random code on top of my table, so that was alleviated. Thanks anyway, guys!
  5. Thanks, but isn't the frequency I have on there rolling once? The "writing it down in pseudo code and plain English" isn't going to help me, I do better visually and not kinetically. I have the code as it what was explained in my class, the only issue is I do not know exactly where the 5000 goes (which I think it will go in the for loop) and why the random extra numbers are showing up in the left hand corner. Code is showing one roll!!!
  6. I tried putting it in my for loop and it didn't work. It gave me the same problem, but instead of only one number, it has given me a random 6 digit code underneath the title. "There's also a problem with your code: //Frequency of Die $frequency1 = 1; $frequency2 = 2; $frequency3 = 3; $frequency4 = 4; $frequency5 = 5; $frequency6 = 6;If those variables count the number of times each face was rolled then shouldn't they start at 0?" Here is what the part of my assignment says: "Inside the PHP code block, create six variables to store the frequency of each side of the die. Choose your variable names wisely. For example, you may name them $frequency1, $frequency2 ……" so it doesn't start with 0. Finally I am not sure exactly where to put the 5000 at. I tried to put it in the Maximum Num Constant, but that didn't work, as it gave me 5000 "errors". Thanks!
  7. 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: <!DOCTYPE html> <?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> </html> 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!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.