Question: Problem 1 [ 5 points]: The value of pi (it) can be approximated using a Monte Carlo method by generating random points inside a square.

 Problem 1 [ 5 points]: The value of pi (it) can

Problem 1 [ 5 points]: The value of pi (it) can be approximated using a Monte Carlo method by generating random points inside a square. Consider the figure above: the ratio of the areas can be expressed using the formula: aredofthesquareareaofthecircle=totalnumberofpoints(red+5tiin)numberofpointsinsidethecircle(red) From (1) you can derive the following equation: =4latalnamberofpoints(rit+ihie)numberofpointsinsidethecircle(red)(2) Your task is to write an app class caled PiApproximation that will vie this approach to aporoximate pi (a) to wiahin th of the astual value (represented here by Math. PI). Your code should: - ask the usee for the value of c[1 pt] - call a method called approxinate (you need to write it, which given , will use the appeoach described above fyou will need to use Randon classk to approximate and return the value of pi (nate you 00NT need any wisualications just a textual output such as the ane below) [4 pts]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!