Homework#4.pdf - Homework#4 Yuan Zhao 1 private static...

This preview shows page 1 out of 1 page.

Homework#4Yuan Zhao 1: private static boolean pointIsInCircle(double xCoord, double yCoord) {if (((xCoord-1.0)*(xCoord-1.0)+(yCoord-1.0)*(yCoord-1.0))<1)return true;else return false;}2: private static int numberOfPointsInCircle(int n) {Random rnd = new Random1L();int c=0, pointIsInCircle=0;while (c < n) {double x = 2 * rnd.nextDouble();double y = 2 * rnd.nextDouble();c++; if (((x - 1) * (x - 1)) + ((y - 1) * (y - 1)) < 1) {

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture