Write a program that simulates the rolling of two dice. The program should use rand twice to roll the first die and second die, respectively. The sum of the two values should then be calculated. [Note: Because each die can show an integer value from 1 to 6, then the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 the least frequent sums.] Figure below 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. 1 2 3 4 5 6 1 2 3 4 5 6 7 3 4 5 6 7 8 3 4 5 6 7 8 9 5 6 7 8 9 10 2 4 6 7 8 9 10 11 7 10 11 12 LO

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 15E: (Program) Write a program to simulate the rolling of two dice. If the total of the two dice is 7 or...
icon
Related questions
Question
Write a program that simulates the rolling of two dice. The program should use rand twice to roll the first
die and second die, respectively. The sum of the two values should then be calculated. [Note: Because
each die can show an integer value from 1 to 6, then the sum of the two values will vary from 2 to 12, with
7 being the most frequent sum and 2 and 12 the least frequent sums.] Figure below 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.
4 5 6
1 2
1 2 3 4 5 6 7
2
5 6 7
3
4
3
4 5 6 7 8 9
5 6
7 8 9 10
4
5.
6 7 8 9 10 11
7
9 10 11 12
Transcribed Image Text:Write a program that simulates the rolling of two dice. The program should use rand twice to roll the first die and second die, respectively. The sum of the two values should then be calculated. [Note: Because each die can show an integer value from 1 to 6, then the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 the least frequent sums.] Figure below 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. 4 5 6 1 2 1 2 3 4 5 6 7 2 5 6 7 3 4 3 4 5 6 7 8 9 5 6 7 8 9 10 4 5. 6 7 8 9 10 11 7 9 10 11 12
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning