homework 4.pdf - Homework#4 1 2 double distance =...

This preview shows page 1 out of 1 page.

Homework #4double distance = Math.sqrt ( (xCoord - 1.0) * (xCoord-1.0) + ( yCoord - 1.0) * (yCoord - 1.0));1.if ( distance <= 1.0) {pointIsInCircle = true;}if( distance > 1.0) {pointIsInCircle = false;}return pointIsItCircle;2. int numberOfPointsInCircle = 0;for ( int i = 1, i <= n, i++){double r = Math.random( );double x = 2.0 * r;r = Math.random( );double y = 2.0 * r;if ( pointIsInCircle(x, y) = true){numberOfPointsInCircle ++;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture