Create a Dice class and simulate 100 rolls, tracking specific sums
Workbook 2a, p.64-65 — Exercise 2
Create a Dice class with a roll() method that returns a random number
from 1 to 6. In your main program, create two Dice objects and roll them both 100
times. Each roll, print the two values and their sum. Keep counters for how many times the sum
equals 2, 4, 6, or 7. After all 100 rolls, display the final counts.
Sample Output (showing first few and last few of 100 rolls)
The *** marks indicate rolls where the sum matched one of the tracked values (2, 4, 6, or 7). Your numbers will differ each run since dice are random.
Dice class is its own file with one job — generate a random value from 1 to 6 when roll() is called. The main program creates objects from it and handles the looping and counting.
This exercise reinforces these concepts from Week 2:
Each run will produce different results because dice rolls are random. That's expected.