CSE2221 HW4.docx - 1 private static boolean...

This preview shows page 1 - 2 out of 2 pages.

1. private static boolean pointIsInCircle(double xCoord, double yCoord) { boolean inCircle=false; if((xCoord-1) * (xCoord-1) + (yCoord-1) * (yCoord -1) <=1) { inCircle=true; } return inCircle; } 2. private static int numberOfPointsInCircle(int n) { int number=0; int i=0; double x=0; double y=0; while(i<n){ x = 2 * rnd1.nextDouble(); y = 2 * rnd2.nextDouble(); if(pointIsInCircle(x,y)){ number+=1; } i++ } return number; } 3. public static void main(String[] args) {

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture