C 7-A Minor Program Dice Randomization

docx

School

Lone Star College System, Woodlands *

*We aren’t endorsed by this school

Course

1315

Subject

Industrial Engineering

Date

Feb 20, 2024

Type

docx

Pages

4

Uploaded by MateBat2484

Report
1 Ch 7-A Minor Program: Dice Randomization Overview: Declare and initialize an array that will represent all possible roll values of two six-sided dice name totalRoll Declare and initialize an array that will represent all possible roll values by a single dice named firstDiceRoll Declare and initialize an array that will represent all possible roll values by a single dice named secondDiceRoll Create your loop that represents 10 dice rolls Run your random function for the first dice and save the value in a variable Run your random function for the second dice and save the value in a second variable Determine the total roll by adding the two dice rolls together Print the results as dice1 + dice2 = total (see output) Increment the totalRoll array element using total value from step 3 as the index of your array Increment the firstDiceRoll array element using the individual result of the first dice as the index of your array Increment the secondDiceRoll array element using the individual result of the second dice as the index of your array Print the values of your arrays once the loop is finished and validate that your program is counting the rolls correctly Once you are sure of the correctness of your algorithm, then comment out the individual rolls print statement (dice1 + dice2 = total) and run it for 1,000 rolls. Make sure you format the numbers so they line up in the tables like the sample output NOTE : Because we are using the random function, your output will not match mine.
2 Output for 10 rolls 2 + 5 = 7 6 + 5 = 11 3 + 4 = 7 4 + 3 = 7 1 + 6 = 7 5 + 2 = 7 3 + 6 = 9 6 + 4 = 10 5 + 1 = 6 2 + 6 = 8 Number of times first individual dice value was rolled: Roll Value Times Rolled % Rolled 1 2 10.0% 2 3 15.0% 3 3 15.0% 4 3 15.0% 5 4 20.0% 6 5 25.0% Number of times second individual dice value was rolled: Roll Value Times Rolled % Rolled 1 2 10.0% 2 3 15.0% 3 3 15.0% 4 3 15.0% 5 4 20.0% 6 5 25.0% Number of times each total dice value was rolled: Roll Value Times Rolled % Rolled 2 0 0.0% 3 0 0.0% 4 0 0.0% 5 0 0.0% 6 1 10.0% 7 5 50.0% 8 1 10.0%
3 9 1 10.0% 10 1 10.0% 11 1 10.0% 12 0 0.0%
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
4 Output for 1000 rolls Number of times first individual dice value was rolled: Roll Value Times Rolled % Rolled 1 3341 16.7% 2 3287 16.4% 3 3314 16.6% 4 3414 17.1% 5 3253 16.3% 6 3391 17.0% Number of times second individual dice value was rolled: Roll Value Times Rolled % Rolled 1 3341 16.7% 2 3287 16.4% 3 3314 16.6% 4 3414 17.1% 5 3253 16.3% 6 3391 17.0% Number of times each total dice value was rolled: Roll Value Times Rolled % Rolled 2 285 2.9% 3 555 5.5% 4 813 8.1% 5 1088 10.9% 6 1416 14.2% 7 1684 16.8% 8 1351 13.5% 9 1133 11.3% 10 818 8.2% 11 556 5.6% 12 301 3.0%