473,508 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

3 dice rolling program

1 New Member
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?
Enter your choice here: -9
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
....

Please help!
Jan 17 '08 #1
2 3374
gpraghuram
1,275 Recognized Expert Top Contributor
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?
Enter your choice here: -9
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
....

Please help!

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 Recognized Expert Contributor
Take a look at this threat (that was on page 1 of the c++ forum).Here
Jan 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1942
by: lawentzel | last post by:
I am new to PHP and am an avid RPG gamer. I am looking to use PhpMyChat to be able to game with friends all over the US. With that having been said, PhpMyChat seems to offer a lot of what I am...
101
6291
by: Elijah Cardon | last post by:
Let's say I have m dice having n sides, such that n^m is not going to bust int as a datatype. With m=4 and n=6, an outcome might be {2, 5, 1, 2}. What is a good way to represent this in c so that...
4
6350
by: dpp4669 | last post by:
I need help with writing a program to use randmax and the standard deviation when u roll the dice 10000 times I know you will need the standard dev. and the average where do i put the randmax and do...
17
9569
by: Jose Durazo | last post by:
Hello, I'm doing an exercise to simulate rolling a pair of dice 36,000 times, then count and display how many times the simulation rolls each possible sum. For some reason each time I run my...
1
6201
by: lenest | last post by:
I need help writing a program.... You are to write a python program to accomplish the following: a.. Play a dice game of Craps using a random number generator to simulate the roll of the...
4
4110
by: vegtard | last post by:
simple question. is it possible to write a script that rolls a six sided dice? if this is possible, is it possible to tell it to roll the six sided dice 4 times and ignore the dice that rolled...
38
9086
by: d0ugg | last post by:
I'm writing a program that will have to roll the dice A and dice B one million times, and calculate the percentage of times that the dies will be equal. I'm having trouble to figure out how the...
4
6024
by: clairelee0322 | last post by:
Hello guys again! I am a C++ beginner and I am working on another project.. It's called Dice Lab with Loops.. unforunately I don't even know how to start the program.... Don't blame me for not pay...
1
1788
by: clairelee0322 | last post by:
I am a c++ beginner and i am working on a dice loop lab. This program should roll two dice (each dice is from 1 to 6) and then total them together. The user should be able to input how many times...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.