Question: Write a Java method with name calculatePI() which founds and return the approximate value of PI number using the following approach: The method should create

 Write a Java method with name calculatePI() which founds and return

Write a Java method with name calculatePI() which founds and return the approximate value of PI number using the following approach: The method should create two random numbers between 0 and 1. (you will use Math.random()) You are going to use these numbers to simulate a shoot to a square target with side length 2. Suppose that you make shoot to this target, if your shot within or on the unit circle this shot accepted as valid. Otherwise, it is considered as invalid shot. Ratio of valid shot to total amount of shot is proportional to ratio of area of circle to area of square. Using this information you will calculate approxiamate value of PI number. The method should print the caluclated value of PI with one siginficant figures and it also return this PI value Assume that the method does not take any parameters and you are going to make 100000 shots in total. For example: \begin{tabular}{|l|l|} \hline Test & Result \\ \hline calculatePI() & 3.1 \\ \hline \end{tabular}

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!