Objective
The main objective of this assignment is to gain some practice with user defined methods for breaking a problem into smaller pieces and organizing your program.
In addition you will gain further practice with variables (local and global), expressions, and conditional statements. This is also your first assignment where you must write a program to complete a specific, narrowly defined task.
Program Specification
Ever wonder how anyone figures out the value of π, which is 3.1415...? You should recall that the area of a circle is π*r2. Let R be the ratio of the area of a circle to the area of a square in which that circle is inscribed. That gives us:
R= (π*r^2)/ ((2r)^2)
Solving this equation for pi gives: π = 4R
We can use simulation to estimate the ratio R of the area of a circle with diameter 1 to that of a square with sides equal to 1. Imagine drawing a circle inscribed in a square as shown here:

We are going to simulate dropping stones uniformly at random within the square. We can then estimate the ratio of the two areas by counting how many stones land within the circle compared to the total number of stones within the square. If that ratio is R, then an estimate of π is 4R.
For this assignment you will create such a simulation. Your "boss" has already completed the top level design and determined that the program should be implemented by creating three functions. Your job is to complete those three functions and combine them into a complete program.
At the heart of the algorithm is the method runOneTrial() which will simulate dropping one stone on the square and update two global variables, numTrials (the number of stones dropped in this simulation) and inCount (the number of stones that landed within the circle). The location and size of the circle is controlled by global variables circleRadius, circleX, and circleY. To perform its task, runOneTrial() will compute one random number x in the range circleX-circleRadus to circleX+circleRadius and another y in the range circleY-circleRadius to circleY+circleRadius. Think of (x, y) as the coordinates of where the stone landed within your square with sides of length 2*circleRadius centered at (circleX, circleY). If that point, (x, y), is also at most circleRadius units from the center of the circle then it is also within the circle.
To make your program modular, you will create a method isIn(float x, float y) that returns true if a stone dropped at (x, y) is also within the circle specified by the global variable circleX, circleY, and circleRadius and return false otherwise. This method should be called when needed by runOneTrial(). Conveniently, processing provides us a built in function, dist() that can be used to compute the distance between two points, just the value we need to know if our point (x, y) is within one circle radius of the center of the circle.
You will need to write a third function/method runTrials() that takes one integer specifying the number of trials to run. This function will call runOneTrial() repeatedly.
Finally, you will need to implement a draw() method that each frame runs some specified number of tests and displays the current estimate of pi along with the number of stones that have been dropped. Note that the method runOneTrial() will need to be modified to not only update the global counts numTrials and inCount, but should also simulate the dropping of the stone by drawing a point on the screen. The color of the point should be determined by whether the stone was determined to have landed in our out of the circle.
Getting Started
Write the method isIn(). Test it by calling it with mouseX, mouseY drawing a point at (mouseX, mouseY) in a color that is determined by the result returned from isIn(). You should see a circle inside of a square appear like rubbing a pencil on a piece of paper placed over a coin.
Write the method runOneTrial(). Test it by calling it from draw(). You should see points beginning to appear on the screen (although rather slowly). You should also print out numTrials and inCount and see that inCount is about 75% the size of numTrials.
Write the method runTrials() and call that from draw(). Experiment with how many trials to run each frame in order to have the simulation progress at a satisfactory rate.
Finish up by adding code to display the improving estimate and the number of trials that have been run. These should appear in sketch display not just in the console window (i.e. draw the text with text() rather than print it with println()). Note you will NOT want to redraw the entire background each frame. Doing so would erase all of the stones dropped during the previous frame. Instead, for the text area of the display you will need to "erase" the old text by first drawing an appropriately sized rectangle over the text area.