Dice Rolling Program help

• 08-17-2005
courtesan
Dice Rolling Program help
I can't seem to get this program down right and it's due by midnight tonight. If anyone could help me out with this code, it would be much appreciated. Here's the assignment:

This project is designed to give you experience working with arrays and passing arrays to functions.

The program you write will simulate the rolling of a pair of dice for as many times as the user wishes, up to 30,000 times. You will keep track of how many times a particular value is rolled, by having an array of counters. The possible values will be 2 through 12. The value 2, aka snake eyes, can only be produced when each of the two dice have come up 1's. Likewise, the value 12, aka boxcars, can only be produced when each of the two dice have come up with the value 6.

The other values (the values between 3 and 11) will tend to occur more often than either the snake eyes or the boxcars, because there is more than one roll possible to create those values. The 3 could be gotten by die #1 rolling a 1, and die #2 rolling a 2 OR by die #1 rolling a 2 and die #2 rolling a 1. So theoretically, it is twice as likely that a 3 will be rolled, rather than a 2 or a 12. Other values rolled will exhibit other probabilities.

The basic project is to simply simulate the rolling of two dice and count how many times each of the possible values was rolled. The counts are to be stored in an array. After all of the rolling is complete, print out the value and the number of times it was rolled. DO NOT ATTEMPT TO STORE THE INDIVIDUAL VALUES ROLLED IN AN ARRAY. Your book can really help you out with this project, since it gives an example of a similar program. You are rolling two dice, rather than one...AND...you MUST have at least one function that takes the array as an argument. I would suggest PrintCounts as a logical choice of such a function.

You should do most of your work in functions. I would suggest that you write a function called RollDice, which would return the result of rolling 2 dice. (The sum of two individual die rolls). You should also have a function that will print out the number of rolls that occurred for each possible value. You may have other functions if you like. Your output should be formatted so that the values and number of occurrences line up in columns as shown below.

Thanks!

- Courtesan
• 08-17-2005
Brian
• 08-17-2005
quzah
And in case you're too busy or something else to click a link...

Quote:

Originally Posted by kermi3
Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Make sure you have a look at the the posting guidelines:
http://cboard.cprogramming.com/annou...ouncementid=51
Following the rules will ensure you get a prompt answer to your question.

Remember, too, that the board has a search facility, a link is at the top of your screen:
http://cboard.cprogramming.com/search.php
It will often get you a quicker answer to your questions than waiting for a response to one you have posted.

It appears that you are posting a homework assignment or other project.

Please don't ask people to do all your work for you, See the announcement on Homework at the top of all forums to see what is acceptable or PM me. Basically people are happy to help, but they're not going to do it all for you.

Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept.

On obivous homework questions especially, I like to remind people of the board's ninth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations.

Feel free to PM me with any questions.

Good Luck,

Kermi3