CSE2221 HW 4.docx - CSE 2221(12:40 Instructor Boggus...

This preview shows page 1 out of 1 page.

CSE 2221 (12:40)Instructor: BoggusSeptember 3, 2018Homework 41.private static boolean pointIsInCircle(double xCoord, double yCoord) {if (Math.sqrt(Math.pow((xCoord - 1), 2))+ Math.pow((yCoord - 1), 2) <= 1) {boolean check = true;return check;} else {return false;}}2.private static int numberOfPointsInCircle(int n) {int count = 0;Random rnd = new Random1L();Random rnd2 = new Random1L();int numInCircle = 0;while (count < n) {double x = 2 * rnd.nextDouble();double y = 2 * rnd2.nextDouble();boolean inCircle = pointIsInCircle(x, y);if (inCircle == true) {numInCircle++;}count++;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture