Homework 4.docx - Jacob Mayhew CSE 2221-SW 1 Components...

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

Jacob MayhewCSE 2221-SW 1: ComponentsProfessor Matt BoggusSeptember 7, 2020Homework 4: Static Methods1.private static boolean pointIsInCircle(double xCoord, double yCoord) {double radius = 1.0;boolean pointIsInCircle == true;if ((xCoord*xCoord)+(yCoord*yCoord)< radius) {return pointIsInCircle;}else {pointIsInCircle == false;return pointIsInCircle;}}2.private static int numberOfPointsInCircle(int n) {int ptsInSquare=0; ptsInCircle;Random rnd = new Random1L();while (ptsInSquare < n) {double x = 2 * rnd.nextDouble();double y = 2 * rnd.nextDouble();ptsInSquare++;if ((x*x)+(y*y)<1) {ptsInCircle++;}}return ptsInCircle;}3.public static void main(String[] args) {

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture