Description
Hint: If you want a step-by-step on how to:
a. Create a method rollDie that uses Math.random() to pick a number from 1 to 6 and returns the number.
b. Create a method rollDice that calls the rollDie method twice to get the total of the two dice and returns the total.
c. Create a one dimensional array to store the number of times for each result. i.e. initially the array has all zeros. If you roll a 2, increment the 2 spot in the array so it will become 1. If you then roll another 2, increment it again so it becomes 2. If you roll a 9, increment the 9 spot.
d. Write a loop in the main method that loops 36,000 times calling the rollDice method and tracking the results in the array.
e. Print out how many times each total was rolled.
Reviews
There are no reviews yet.