Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: Imagine a giant square painted outdoors, on the ground, with a painted circle inscribed in it Next, image that its raining and that we

Java:

Imagine a giant square painted outdoors, on the ground, with a painted circle inscribed in it Next, image that its raining and that we have the ability to monitor every raindrop that hits inside the square. Some of those raindrops will also fall inside the circle, and a few will fall in the corners and be inside the square, but not inside the circle. Keep a tally of the raindrops that hit inside the square (sqrCount) and those that also hit inside the circle (cirCount). The ratio of these two counts should equal the ratio of the areas as follows: (Understanding this statement is essential. It is the very premise of this problem.) sqrCount / cirCount = (Area of square) / (Area of circle) sqrCount / cirCount = side2 / ( * r2 ) Solving for from this equation we get = cirCount * (side2

) / (sqrCount * r2 )

So why did we solve for ? We already know that its 3.14159. We simply want to illustrate that by a simulation (raindrop positions) we can solve for various things, in this case something we already know. The fact that we already know just makes it that much easier to check our answer and verify the technique.

We are going to build a class called MonteCarlo in which the constructor will establish the size and position of our square and circle. Public state variables inside this class will be h, k, and r. These are enough to specify the position and size of our circle and square as shown in the figure to the right.

-use Math.random() instead of the Random class.

-Add a GUI (Graphical User Interface) to Monte Carlo.

Try to use a single conversion to find graphical coordinates fom the oiginal (x, y).

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

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions

Question

Make efficient use of your practice time?

Answered: 1 week ago