package rebelsky.arrays; import java.io.PrintWriter; /** * Some fun tests with arrays. * * @author Samuel A. Rebelsky * @version 1.0 of October 2004 */ public class Test { public static void main(String[] args) throws Exception { PrintWriter pen = new PrintWriter(System.out, true); Computer c = new Computer(); double[] values = new double[]{ 3.5, 2.4, 6.0 }; // Print the array. pen.print("Original array: ["); pen.print(values[0]); for (int i = 1; i < values.length; i++) pen.print("," + values[i]); pen.println("]"); // Test sum. pen.println("Sum is " + c.sum(values)); // Test Fibonacci for (int n = 0; n <= 45; n++) { long start = System.currentTimeMillis(); long result = c.fibr(n); long finish = System.currentTimeMillis(); pen.println("fib(" + n + ") = " + result); pen.println(" Computation took " + (finish-start) + " milliseconds"); } } // main(String[]) } // class Test