Project 49: Sum of Three Dice

If you were to roll 3 fair dice, the sum of the dice could be anywhere from 3 (if you got all 1s) to 18 (if you got all 6s).  

Project 49:  Variable 'k' has been initialized.

Use simulation to conduct MANY (at least 100,000) trials to estimate the probability that the sum of the three dice is K.  You can assume K will be a number between 3 and 18 inclusively.

Task: Appropriately assign the value of 'proportion' to represent the probability that the sum of the three dice is equal to K.


Note: There are two working randomization methods available to use.


random() returns a random number from [0,1)


Example: r = random();  //r holds a value between 0 and 1 (not including 1).


randomInt(lower, upper) returns a random integer between lower and upper inclusive


Example: i = randomInt(2,7); //i holds one of the values: 2, 3, 4, 5, 6, 7 and they are all equally likely

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0