//------------// Introduction to Programming Using Java: An Object-Oriented Approach//	Arnow/Weiss//------------// the squareRoot method// Chapter 9, Section 9.7, Page 350-353// MODIFICATIONS://    squareRoot and closeEnough are made static here so we//	can test them without creating an objectimport java.io.*; class Test_squareRoot {	///////////////////////////////////////////////////////	private static boolean closeEnough(double x, double y, double precision) {		return Math.abs(y*y-x) <= precision;	}	// squareRoot returns square root of x within the given precision.	private static double squareRoot(double x, double precision) {		double y;		y = x;		while (!closeEnough(x, y, precision))			y = (y+x/y) / 2.0;		return y;	}	///////////////////////////////////////////////////////	private static boolean squareRootFailure(double x, double p, double v) {		double w = squareRoot(x,p);		if ( Math.abs(w*w - v*v) >p) {			System.err.println("FAILS: squareRoot("  +  x  +  ","  +  p  +				 ") returns "  +  w  +  " instead of "  +  v);			return true;		} else			return false;	}	public static void main(String[] a) {		double precision=0.00001;		boolean failure=false;		failure |= squareRootFailure(4.0,precision,2.0);		failure |= squareRootFailure(144.0,precision,12.0);		failure |= squareRootFailure(1000000.0,precision,1000.0);		if (!failure)			System.out.println("squareRoot passes our tests");	}}