471,829 Members | 1,884 Online

# 3 dice rolling program

Anybody know how to write a 3 dice rolling program like this

Sample output

Welcome to the dice roller!

First of all, please enter a seed for the random number generator. This should be a positive integer: 3

How many times would you like me to roll the 3 dice?
Sorry, please enter a positive number: 100

Okay, I’ll roll the dice 100 times and find the sum each time.

Here are the results:

Sum Frequency
3 0
4 1
5 3
6 3
7 6
8 15
9 12
10 18
11 13
12 13
13 3
14 6
15 4
16 3
17 0
18 0
....

Jan 17 '08 #1
2 3249
gpraghuram
1,275 Expert 1GB
Anybody know how to write a 3 dice rolling program like this

Sample output

Welcome to the dice roller!

First of all, please enter a seed for the random number generator. This should be a positive integer: 3

How many times would you like me to roll the 3 dice?
Sorry, please enter a positive number: 100

Okay, I’ll roll the dice 100 times and find the sum each time.

Here are the results:

Sum Frequency
3 0
4 1
5 3
6 3
7 6
8 15
9 12
10 18
11 13
12 13
13 3
14 6
15 4
16 3
17 0
18 0
....

As the question say you should use the seed function and call the rand function to get the number.
In a single dice maximum number is 6 and so whatever number you get mod it(%) by 6 to get a single dice value and same process for other piece.
Now you have value for one dice.
Youe should be using same logic for 3 pair of dice.
Hope you are understanding this

Thanks
Raghuram
Jan 17 '08 #2
Studlyami
464 Expert 256MB
Take a look at this threat (that was on page 1 of the c++ forum).Here
Jan 17 '08 #3