Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions Write a C++ program, named DiceRoll.cpp, that contains a function named roll ) * Return type: int Name: roll Parameters: o int sides: number
Instructions Write a C++ program, named DiceRoll.cpp, that contains a function named roll ) * Return type: int Name: roll Parameters: o int sides: number of sides in the die o double *weights: a pointer to an array of weight values for each side in the die weights [0]: weight value for Side 1 weights [1]: weight value for Side 2 This function should simulate a roll of the weighted die, given its number of sides and weight values for each side. It should return a value between 1 and sides. In the main () function, test the roll ) function by calling it 100,000 times and keeping track of the number of rolls for each side of a weighted coin flip Die with 2 sides (sum of all weights -2 0.5 2.5) Side Weight Probability 2 / 2.5 80% 0.5 12.5 20% 0.5
Step 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