Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODE IN C++ Dice Roll Statistics Write a program that simulates rolling a pair of time some specified number of times, and reports the number

CODE IN C++

Dice Roll Statistics

Write a program that simulates rolling a pair of time some specified number of times, and reports the number of times each total value (2 through 12) was rolled as well as the number of times each possible double is rolled (i.e. double 1's, double 2's, etc.).

Output your results in two nicely formatted, side-by-side tables as shown in the sample program runs below.

The table on the left should show the possible total values that can be rolled with the number of and percentage of times each was rolled.

The table on the right should show the number of and percentage of times each possible double was rolled. This table should also show a total number and percentage of all six possible doubles.

The input to the program should be the number of rolls that are to be simulated. Optionally, this value should be able to be passed on the command line, in which case no prompt should be issued. Also, the program should accept only values of 1 through 100000 for the number of dice rolls. This functionality is already provided in the starter code.

Here are three sample runs for input values of 10, 1000, and 100000. Your output should be formatted as shown in the samples.

*** Dice Roll Statistics ***

Enter number of dice rolls: 10

Roll Count Percent Double Count Percent ---- ----- ------- ------ ----- ------- 2 0 0.0% 1 0 0.0% 3 2 20.0% 2 0 0.0% 4 0 0.0% 3 1 10.0% 5 1 10.0% 4 0 0.0% 6 2 20.0% 5 0 0.0% 7 1 10.0% 6 0 0.0% 8 0 0.0% ----- ----- 9 2 20.0% 1 10.0% 10 1 10.0% 11 1 10.0% 12 0 0.0%

*** Dice Roll Statistics ***

Enter number of dice rolls: 1000

Roll Count Percent Double Count Percent ---- ----- ------- ------ ----- ------- 2 32 3.2% 1 32 3.2% 3 54 5.4% 2 27 2.7% 4 95 9.5% 3 28 2.8% 5 123 12.3% 4 23 2.3% 6 140 14.0% 5 26 2.6% 7 160 16.0% 6 27 2.7% 8 135 13.5% ----- ----- 9 106 10.6% 163 16.3% 10 87 8.7% 11 41 4.1% 12 27 2.7%

*** Dice Roll Statistics ***

Enter number of dice rolls: 100000

Roll Count Percent Double Count Percent ---- ----- ------- ------ ----- ------- 2 2815 2.8% 1 2815 2.8% 3 5496 5.5% 2 2793 2.8% 4 8365 8.4% 3 2732 2.7% 5 11037 11.0% 4 2818 2.8% 6 13832 13.8% 5 2757 2.8% 7 16722 16.7% 6 2779 2.8% 8 13991 14.0% ----- ----- 9 11057 11.1% 16694 16.7% 10 8319 8.3% 11 5587 5.6% 12 2779 2.8%

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions