Rewrite the main method in your solution to the Monte...

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

Jay Patel Instructor: Robert Latour CSE 2221 (4:10) SP19 01/17/2019 Homework: Static Methods 1. Implement (i.e., provide the code for the body of) the static method declared as follows: A1 : private static boolean pointIsInCircle( double xCoord, double yCoord) { if (( xCoord 1.0) * ( xCoord 1.0) +   ( yCoord 1.0 ) * ( yCoord 1.0 ) ) < 1.0 ) { return true; } else { return false; } } 2. Implement the static method declared as follows: A2: private static int numberOfPointsInCircle( int n) { int num = 0; Random rnd = new Random1L(); for (int i = 0; i < n; i++) { double xCoord = 2.0 * rnd.nextDouble(); double yCoord = 2.0 * rnd.nextDouble(); if (pointsIsCircle(x,y)) { num++; } } return num; }
3. Rewrite the main method in your solution to the Monte Carlo estimation of π lab so that it uses numberOfPointsInCircle (and indirectly pointIsInCircle).

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture