Lab 2: Counting Rolls of the Dice

Due Date: midnight Wednesday, September 18, 2002


Background:

This lab will provide you with the opportunity to work with classes and objects as well as review arrays. Once you're done, you will use the Intro-CS Assignment Dropoff form to hand in your finished program.


What You'll Need

Download the lab2.zip file from the 15-111 course web site. Unzip the files and you should see the following:


Assignment

You are to prompt the user for a number of times to roll a pair of dice. You are then to cause a pair of dice to be rolled that number of times and tally each roll's sum (possible values 2 through 12) using an array to tally (count) the number of times each sum occurs.

When you're finished rolling, you should print a histogram of the tallies. Two sample runs of my solution follows below:


Enter number of rolls: 1000

Sum     Count   Histogram
2       32      ****
3       52      ******
4       73      ********
5       103     ***********
6       142     ***************
7       173     ******************
8       133     **************
9       122     *************
10      87      *********
11      56      ******
12      27      ***


Enter number of rolls: 100

Sum     Count   Histogram
2       1       *
3       4       *
4       11      **
5       10      *
6       11      **
7       22      ***
8       15      **
9       12      **
10      9       *
11      4       *
12      1       *

Your counts, of course, should sum to the number of rolls that were requested, and your histogram should look something like mine (I used one * for each 10 tallies).


Handing in your Solution

Your solution should be in the form of a .zip file. When we grade your solution we will unzip the folder and execute the Java files.

Use the Intro Programming dropoff form to submit your zip file.