Homework 4.docx - Homework 4 Jiashu Zhang 1 Checks whether...

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

Homework 4Jiashu Zhang1./*** Checks whether the given point (xCoord, yCoord) is inside the circle of* radius 1.0 centered at the point (1.0, 1.0).* * @paramxCoord* the x coordinate of the point* @paramyCoord* the y coordinate of the point* @returntrue if the point is inside the circle, false otherwise*/privatestaticbooleanpointIsInCircle(doublexCoord, doubleyCoord){if((xCoord-1)*(xCoord-1)+(yCoord-1)*(yCoord-1)<=1)returntrue;elsereturnfalse;}2./*** 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* point (1.0, 1.0).** @paramn* the number of points to generate* @returnthe number of points that fall in the circle*/privatestaticintnumberOfPointsInCircle(intn) {intptsInInterval = 0, ptsInSubinterval = 0;Random rnd = newRandom1L();while(ptsInInterval

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture