HW4.docx - Xian Zhang.6757 CSE 2221 Ben Trevor 10:20-11:15...

This preview shows page 1 out of 1 page.

Xian Zhang.6757 CSE 2221 Ben Trevor 10:20-11:15 1/23/18 Homework 4 1. private static boolean pointIsInCircle(double xCoord, double yCoord) { boolean x = false; if (Math.sqrt(Math.pow(xCoord - 1, 2.0) + Math.pow(yCoord - 1, 2.0)) <= 1) { x = true; } else{ } return x; } 2. private static int numberOfPointsInCircle(int n) { Random rnd = new Random1L(); while (ptsInInterval < n) { double xCoord = 2 * rnd.nextDouble(); double yCoord = 2 * rnd.nextDouble(); boolean circleCheck = pointIsInCircle.( xCoord , yCoord); if(circleCheck){ ptsInSubinterval++;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture