3 dice rolling program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunnydude
    New Member
    • Jan 2008
    • 1

    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?
    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!
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by sunnydude
    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

    Comment

    • Studlyami
      Recognized Expert Contributor
      • Sep 2007
      • 464

      #3
      Take a look at this threat (that was on page 1 of the c++ forum).Here

      Comment

      Working...