Write a program that accepts the number of darts as an


Monte Carlo techniques can be used to estimate the value of pi. Suppose you have a round dart board that just fits inside of a square cabinet. If you throw darts randomly, the proportion that hit the dart board vs. those that hit the cabinet (in the corners not covered by the board) will be determined by the relative area of the dart board and the cabinet. If n is the total number of darts randomly thrown (that land within the confines of the cabinet), and h is the number that hit the board, it is easy to show that

2427_cfd90810-4b46-4411-8fd7-3a36ea2699f4.png

Write a program that accepts the "number of darts" as an input and then performs a simulation to estimate π. Hint: you can use 2*random() - 1 to generate the x and y coordinates of a random point inside a 2x2 square centered at (0, 0). The point lies inside the inscribed circle if x2 + y2 ≤ 1.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write a program that accepts the number of darts as an
Reference No:- TGS01707761

Expected delivery within 24 Hours