UNB/ CS/ David Bremner/ teaching/ java/ SqrtTest4.java
import java.util.Random;

public class SqrtTest4 
{  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);
         
         // check that test value fulfills square property
         
         if (Numeric.approxEqual(y * y, x))
            System.out.println("Test passed.");
         else
            System.out.println("Test failed.");
         System.out.println("square root of " + x
            + " = " + y);
      }
   }
}