Question
C++ - Write a program that simulates the rolling of two dice. The program should use rand to roll the first die and should use
C++ - Write a program that simulates the rolling of two dice. The program should use rand to roll the first die and should use rand again to roll the second die. The sum of the two values should then be calculated. [Note: Each die can show an integer value from 1 to 6, so the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the least frequent sums.] Figure 7.32 shows the 36 possible combinations of the two dice. Your program should roll the two dice 36,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Print the results in a tabular format. Also, determine if the totals are reasonable (i.e., there are six ways to roll a 7, so approximately one-sixth of all the rolls should be 7).
5 6 2 1 2 3 4 1 2 3 4 5 6 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 6 7 8 9 10 11 6 7 8 9 10 11 12 5 Sampe Output Sum 2 3 4 5 6 7 8 9 Total Expected Actual 983 2.778% 2.731% 1918 5.556% 5.328% 2952 8.333% 8.200% 4138 11.111% 11.494% 4964 13.889% 13.789% 5952 16.667% 16.533% 5062 13.889% 14.061% 4007 11.111% 11.131% 3071 8.333% 8.531% 2007 5.556% 5.575% 946 2.778% 2.628% 10 11 12Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started