Dice Throwing Program

 

Dice1

Set up a program that will shake two “dice”.  It will add the two together to get a dice total and report this total.  (Totals will range between 2 and 12). 

 

When reporting the total, you should show Dice1, Dice2, and the Total.

 

Dice2

Loop your main program so that it shakes dice 20 times and reports the result for each shake.  Use the sleep function to pause your program between rolls.

 

Dice3

Adjust your program loop so that it also keeps track of a running total.  This would be the total amount of all dice rolled so far.  This number should report each roll as well.  Final output would look similar to this:

 

Roll #1

Die 1 = 6

Die 2 = 3

Total = 9

Running Total = 9

 

Roll #2

Die 1 = 1

Die 2 = 4

Total = 5

Running Total = 14

 

Roll #3

Die 1 = 5

Die 2 = 3

Total = 8

Running Total = 22

 

…etc

 

Dice4

Adjust your program loop so that it counts the number of time each total has been rolled.  Totals for 2 dice range from 2 – 12.  After your loop completes, the program should reports the number of times each total was rolled.  Example below:

 

Roll #1

Die 1 = 6

Die 2 = 3

Total = 9

Running Total = 9

 

Roll #2

Die 1 = 1

Die 2 = 4

Total = 5

Running Total = 14

 

Roll #3

Die 1 = 5

Die 2 = 3

Total = 8

Running Total = 22

 

…etc…20 rolls

 

[finished looping]

 

Total of Dice

# of instances

2

0

3

2

4

1

5

5

6

5

7

0

8

2

9

2

10

3

11

0

12

0

 

Dice5

Adjust your program loop so that it rolls 20,000 times instead of 20 times.  Assuming Dice4 works well, you may take out the showing of each individual roll.  The object of this program is to see how often, over the course of 20,000 rolls, each total comes up.  Be prepared to use this program to answer questions some questions about your results!