Computer Science 225
Advanced Programming
Spring 2017, Siena College
You will work with a partner on this lab. Only one submission per group is needed.
Getting Set Up
You should have a directory (i.e., folder) in your directory named csis225. Create a directory within csis225 named lab0. Create your BlueJ project for this lab within that folder.
Writing a Simulation Program
Your task is to write a Java program to simulate a series of dice rolls, and report some statistics about them. Specifically, your program should meet these requirements:
For example, if the file dice.txt contains the numbers 6, 8, and 10, and that file is specified as the first command-line parameter and the number 15 is the second command-line parameter, the following is a possible output:
Simulation has 3 fair dice: 6-sided 8-sided 10-sided Roll 1: 4 4 2 total: 10 Roll 2: 2 4 2 total: 8 Roll 3: 3 1 4 total: 8 Roll 4: 4 7 1 total: 12 Roll 5: 5 1 3 total: 9 Roll 6: 6 8 6 total: 20 Roll 7: 1 7 10 total: 18 Roll 8: 3 3 9 total: 15 Roll 9: 3 2 7 total: 12 Roll 10: 3 3 3 total: 9 Roll 11: 4 7 10 total: 21 Roll 12: 2 1 6 total: 9 Roll 13: 3 1 8 total: 12 Roll 14: 5 6 1 total: 12 Roll 15: 6 3 10 total: 19 Simulation summary: Roll counts for 6-sided die: 1:1 2:2 3:5 4:3 5:2 6:2 Roll counts for 8-sided die: 1:4 2:1 3:3 4:2 5:0 6:1 7:3 8:1 Roll counts for 10-sided die: 1:2 2:2 3:2 4:1 5:0 6:2 7:1 8:1 9:1 10:3 Sum counts: 3:0 4:0 5:0 6:0 7:0 8:2 9:3 10:1 11:0 12:4 13:0 14:0 15:1 16:0 17:0 18:1 19:1 20:1 21:1 22:0 23:0 24:0 Average roll: 12.93
As another example, if the file yahtzee.txt contains the number 6 repeated 5 times (indicating 5 standard 6-sided dice), and that file is specified as the first command-line parameter and the number 10000 is the second command-line parameter, the following is a possible output:
Simulation has 5 fair dice: 6-sided 6-sided 6-sided 6-sided 6-sided Roll 1: 6 4 2 5 1 total: 18 Roll 2: 1 1 6 1 6 total: 15 Roll 3: 4 5 1 1 1 total: 12 ... 9994 lines omitted ... Roll 9998: 6 3 3 3 6 total: 21 Roll 9999: 1 1 1 6 5 total: 14 Roll 10000: 5 2 1 3 2 total: 13 Simulation summary: Roll counts for 6-sided die: 1:1637 2:1674 3:1646 4:1694 5:1657 6:1692 Roll counts for 6-sided die: 1:1656 2:1659 3:1634 4:1692 5:1677 6:1682 Roll counts for 6-sided die: 1:1633 2:1674 3:1705 4:1723 5:1636 6:1629 Roll counts for 6-sided die: 1:1698 2:1652 3:1708 4:1641 5:1625 6:1676 Roll counts for 6-sided die: 1:1706 2:1659 3:1641 4:1715 5:1696 6:1583 Sum counts: 5:2 6:5 7:19 8:33 9:84 10:134 11:242 12:421 13:535 14:715 15:868 16:953 17:995 18:1044 19:974 20:861 21:684 22:478 23:366 24:273 25:166 26:86 27:40 28:14 29:6 30:2 Average roll: 17.49
Submitting
Your lab is "submitted" by having your BlueJ project in the approrpriate directory in your account. Your lab will be graded by a demonstration of your program for your lab instructor. The grade is based entirely on correctness, and is worth 100 lab points.