You are on page 1of 1

AP Lab 06b – The Dice Roller program

In the olden days of gaming, random numbers were determined using dice, and different distributions of
random numbers were produced by rolling multiples of dice with specific numbers of sides. There is a
notation which has developed for rolling such combinations of dice, and it’s usually written in the form
xdy. Some examples are:

3d6: roll 3 dice which each have 6 sides.


2d12: roll 2 dice which each have 12 sides.
5d4: roll 5 dice which each have 4 sides.
6d20: roll 6 dice which each have 20 sides.

Even though most modern games use computers for their random numbers, this notation is still
sometimes seen today to suggest what sorts of numbers should be produced. For this lab, you will
create a program which returns the result of rolling dice in this format. The catch – you will not be
provided any starting source code, and must create the program entirely yourself.

For 60 points, create a program which can simulate rolling a six-sided die.

For 70 points, create a program which takes in a number y and simulates rolling a y-sided die.

For 80 points, create a program which takes in a number y and simulates the sum of rolling 3
dice of y sides (3dy).

For 90 points, create a program which takes in two numbers x and y and simulates the sum of
rolling x dice with y sides (xdy).

For 100 points, create a program which does everything from the 90 point version, but also
shows a “picture” of the dice that were rolled if the dice were 6-sided dice. You may do this
with an applet, or you may “print” your dice to the screen with ASCII art.

You might also like