previous | start | next

File RootApproximatorTest5.java

1 import java.util.Random;
2
3 /**
4     This program computes square roots of random inputs.
5 */
6 public class RootApproximatorTest5
7 {  
8    public static void main(String[] args)
9    {  
10       final double SAMPLES = 100;
11       Random generator = new Random();
12       for (int i = 1; i <= SAMPLES; i++)
13       {  // generate random test value
14
15          double x = 1.0E6 * generator.nextDouble();
16          RootApproximator r = new RootApproximator(x);
17          double y = r.getRoot();
18          System.out.println("square root of " + x
19             + " = " + y);
20       }
21    }
22 }


previous | start | next