Click to reopen instructions.

If you fill out the requested methods in this program, it will produce an estimate of the value of π by generating random numbers. The idea is that if we draw a circle inscribed in a square and then throw darts that will each hit the square in a random position, then the number of darts that land in the circle will be proportional to the area of the circle. Since we know the area of a circle is πr2, we can use that proportion to estimate π.

For simplicity we’ll use a circle of radius 1 which means the circle’s area is π and the square it’s inscribed in has sides of length 2 and an area of 4. Thus the ratio of darts that land in the circle to total darts should approach π/4 as we throw more darts and therefore we can estmate π by multiplying that proportion by 4.

If you’ve implemented all the TODOs properly and you increase value of iterations this program will also draw an image like the thumbnail shown to the right, showing where the darts landed and displaying the estimate of π obtained. Note, increasing the value of the iterations variable will get a more accurate estimate of π but if you set it too high, your program will probably be killed before it completes since the server limits how long a program can run.

Put definitions here.

Revisions:

Unit √2: estimate π

Compilation errors