Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

LANGUAGE C++ (Repeat this section for each of your functions). Provide the funct

ID: 3546347 • Letter: L

Question


                            LANGUAGE C++

(Repeat this section for each of your functions). Provide the function prototype here.

Experiments that are either too expensive or too dangerous to perform are often simulated on a computer when the computer is able to provide a good representation of the experiment. Find out how to call the random-number generator (usually a function returning a floating point value in the range 0 to 1) for your C++ system. (Look up the functions rand and srand in the library cstdlib on the website cplusplus.com). Write a program that uses the random-number generator to simulate the dropping of glass rods that break into three pieces. The purpose of the experiment is to estimate the probability that the lengths of the three pieces are such that they might form the sides of a triangle.

For the purposes of this experiment, you may assume that the glass rod always breaks into three pieces. If you use the line segment 0 to 1 (on the real number line) as a mathematical model of the glass rod, a random-number generator (function) can be used to generate two numbers between 0 and 1 representing the coordinates of the breaks. The triangle inequality (the sum of the lengths of two sides of a triangle are always greater than the length of the third side) may be used to test the length of each piece against the lengths of the other two pieces.

To estimate the probability that the pieces of the rod form a triangle, you

Explanation / Answer

#include #include #include #include #include #include #include using namespace std; float doBreak (); float doProbability (float, float); const int SENTINEL = 21; //sentinal value int main() { float count; float tests; float probability; float triangle = 0; count = 1; srand (time (NULL)); cout