import Point;
import java.lang.Math;
import SimpleInput;
import SimpleOutput;


public class approxPi {
    // class provides a framework for checking whether the parentheses
    // in a line of input match

    public static void main (String args []) {

        // declare needed objects
        SimpleInput in = new SimpleInput();
        SimpleOutput out = new SimpleOutput();

        // Other declarations
        int N;         // Number of points to be selected
        int count = 0; // Count of points in circle
        int i;         // loop index
        boolean errorFound = false; // state of checking so far

        // read line from keyboard
        out.println ("Please enter the number of points to be selected");
        N = in.readInt();

        for (i = 0; i < N; i = i + 1) {
            Point P = new Point (Math.random(), Math.random());
            if (P.distanceFromOrigin() <= 1.0)
                count = count + 1;
        }
        
        out.println ("In selecting " + N + " points in the unit square");
        out.println ("in the first quadrant, " + count + " points ");
        out.println ("were also in the unit circle.");
        out.println ("This gives " + 4.0*count/N 
                     + " as an approximation to Pi.");
    }
}
