ITEC 120 LAB 17 Back to Lab index page

Rolling Dice

Modify your lab 16 which rolled 4 dice until they were all the same.

The number of rolls it takes until 4 dice are the same varies greatly. Modify your program so that you can run it many times and get an average number of rolls. Ask the user how many trials they would like to run. For example, if the user entered 50, your program would roll 4 dice until they were the same 50 times, and average together all 50 counts. Report your result to the nearest tenth.

Sample run:

Program displays:

How many trials would you like to run?

User enters: 50
Program displays:

50 trials were run.

It took an average of 215.6 rolls for the dice to be the same.