HW4 - CSE 2221 Homework 4 Young-Gun Lee import...

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

CSE 2221 Homework 4 Young-Gun Lee import components.random.Random; import components.random.Random1L; import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; /** * Monte Carlo Estimate: compute percentage of pseudo-random points in [0.0,1.0) * interval that fall in the left half subinterval [0.0,0.5). */ public final class MonteCarlo { /** * Private constructor so this utility class cannot be instantiated. */ private MonteCarlo() { } /** * Main method. * * @param args * the command line arguments; unused here */ private static boolean pointIsInCircle(double xCoord, double yCoord) { if (((1 - xCoord) * (1 - xCoord) + (1 - yCoord) * (1 - yCoord)) < 1) { return true; }
CSE 2221 Homework 4 Young-Gun Lee return false; } private static int numberOfPointsInCircle(int n) { int ptsInInterval = 0, ptsInSubinterval = 0; /* * Create pseudo-random number generator */ Random rnd = new Random1L();

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture