# Homework #4.docx - Yu Xiong.375 CSE 2221 Prof Grupa 4:10 PM...

• 1

This preview shows page 1 out of 1 page.

Yu Xiong.375 CSE 2221 Prof. Grupa 4:10 PM 08/31/2019 Homework #4 Static Methods 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() { } /** * 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 ) { boolean tf = true ; if ((( xCoord - 1) * ( xCoord - 1) + ( yCoord - 1) * ( yCoord - 1)) < 1.0) { tf = true ; } else { tf = false ; } return tf ; } /** * Generates n pseudo - random points in the [0.0,2.0) x [0.0,2.0) square and * returns the number that fall in the circle of radius 1.0 centered at the