import java.util.Random; public class SqrtTest5 { public static void main(String[] args) { Random generator = new Random(); for (int i = 1; i <= 100; i++) { // generate random test value double x = 1.0E6 * generator.nextDouble(); double y = MathAlgs.sqrt(x); // compare against oracle if (Numeric.approxEqual(y, Math.pow(x, 0.5))) System.out.println("Test passed."); else System.out.println("Test failed."); System.out.println("square root of " + x + " = " + y); } } }