Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribed

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

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

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions