Write a program that stimulates the mathematical experiment of rolling a pair of
ID: 3635295 • Letter: W
Question
Write a program that stimulates the mathematical experiment of rolling a pair of dice any number of times. Let user input this data. The program also lets user pick a choice of output for either partial or all of the following information:1. all random outcomes observed
2. frequency and relative frequency corresponding to the random values defined by the sum of the dots on the dice for each roll
3. text version of histogram
4. graphic version of histogram by a Scalable Vector File
The main source of code that I am having trouble with is displaying the output of the dice rolls. Please show me how to do this. Help with the entire problem would be preferred. Use void functions, do not put everything in the main function.
Explanation / Answer
#include using std::cout; using std::ios; #include using std::setw; using std::setprecision; using std::fixed; using std::showpoint; #include using std::rand; using std::srand; #include using std::time; int main() { const long ROLLS = 36000; const int SIZE = 13; // array expected contains counts for the expected // number of times each sum occurs in 36 rolls of the dice /* Write a declaration of array exprected here. Assign an initializer list containing the expected values here. Use SIZE for the number of elements */ int x; // first die int y; // second die /* Write declaration for the array sum here. Initialize all elements to zero. Use SIZE for the number of elements */ srand( time( 0 ) ); // roll dice 36,000 times /* Write a for statement that iterates ROLL times. Randomly generate values for x (i.e., die1) and (i,e, die2) and increment the appropriate counter in array sum that corresponds to the sum of x and y */ coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.