MonteCarlo.pdf - import import import import...

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

2/10/2021 1/2 import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; /** * Put a short phrase describing the program here. * * @author Ronit Kumar * */ public final class MonteCarlo { /** * Private constructor so this utility class cannot be instantiated. */ private MonteCarlo() { } /** * Checks whether the given point (xCoord, yCoord) is inside the circle of * radius 1.0 centered at the point (1.0, 1.0). * * @param xCoord * the x coordinate of the point * @param yCoord * the y coordinate of the point * @return true if the point is inside the circle, false otherwise */ private static boolean pointIsInCircle(double xCoord, double yCoord) { if ((xCoord - 1) * (xCoord - 1) + (yCoord - 1) * (yCoord - 1) < 1) { out.println("The point is in the circle."); } else { out.println("The point is not in the circle."); } } /** * Generates n pseudo-random points in the [0.0,2.0) x [0.0,2.0) square and

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture