HomeWork4.pdf - Jeff Agyei Grupa January 20th 2020 Homework...

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

Jeff Agyei Grupa January 20 th , 2020 Homework: Static Methods 1. 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. 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. public static void main (String [] args) { /* * Open input and output streams */ SimpleReader input = new SimpleReader1L ();

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture