Question: Write a program that simulates the rolling of two dice many times. Each of the two dice should have a separate Random(6) 1 and the
Write a program that simulates the rolling of two dice many times. Each of the two dice should have a separate Random(6) 1 and the two random values should be added together to get the total of the two dice roll. After rolling the two dice, the total rolled should be updated in an array of counters. For example, if the random values were 3 and 4, then the dice total is 7, and the index 7 element should be incremented by 1. Because the maximum roll possible for two dice is 12, your array of counters should have an upper bound of 12. Your program should simulate rolling the two dice many times (400 rolls is the number used in the figure below) and then display how many times each total was rolled and the percentage for each total. Finally, the program should display the roll totals visually by creating a histogram. Note: Each time you run your program you will get different totals and therefore a different histogram. In general the middle totals (such as 6, 7, 8) should be rolled more often than the extremes (2, 3, 4 on the low end and 10, 11, 12 on the high end) because there are more combinations of two dice that result in those middle values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
