ICS 111 Homework Assignment H05: Simulate a pair of dice.

1) Write a program that simulates rolling a pair of dice. The program will output a table similar to the following:

Average number of tries: 
 # : tries
 2 : 40.30
 3 : 18.80
 4 : 12.29
 5 : 9.11
 6 : 7.10
 7 : 7.19
 8 : 7.44
 9 : 10.69
10 : 10.79
11 : 19.50
12 : 34.25

The program should have a function that return the number of times it takes to roll two six sided dice to get the given number. To calculate the average number of tries your program should call the function several times and sum up the number of tries. Then divide by the number of times the function was called.

2) Bonus Modify your program to have a member variable that stores the number of sides of the dice. Note: This will change the output.

Turning in the Assignment

The assignment is due on Friday at 11:55pm. You may turn it in early.

  1. Conduct a personal review of your code before turning it in. Does your code follow the Java Coding Standard?

    Is it clear and well commented?

  2. Test your code.

    • Does it produce the correct output?
  3. Sign into Laulima, then navigate to the ICS111 site. In the left hand side of the site, there is an Assignments tab/link. Click on it and view all of the posted assignments. Select the assignment that you want to turn in and attach your files and accept the honor pledge to submit the assignment.