Java Genesis
Hints for Chapter 6: Methods
Problem 9: tossing four dice
Here is a scenario:
- create an array tossArray of integers having length 4;
- create an integer count and set it initially to 0;
- now do the following 1,000 times:
- populate the array with random integers in the range 1 to 6;
- increase count by 1;
- test using the method hasNoDuplications to see if the
array has any repeated integers;
- continue doing this until there are no repeated integers;
- find the average by dividing count by 1,000.
Try converting this scenario into code before looking at the last hint:
Next Hint