/*
Purpose:
This program computes the delivery charges for letters and packages
Record of revision:
Date Programmer: Description
==== =========== ===========
18-04-07 M.Helmijr Original code
*/
import java.text.*;
public class Array1 {
//define method
public static void main(String [] args)throws Exception {
//Declares variables
int k; //integer van een getal
int square; //kwadraat van het getal
double root; //wortel van het getal
final int SIZE = 51; //size of the array
//
DecimalFormat df1 = new DecimalFormat ("0.000");
//Create array of proper size
int [] array1 = new int [SIZE]; //array for the sqrt values
double [] array2 = new double [SIZE]; //array for the root values
double [] array3 = new double [50]; //array for verschil between the root and root+1
//While Loop to calculate and print the squares and roots
String res="";
for (k = 0; k < array1.length; k++) {
root = Math.sqrt(k);
array1[k] = k * k;
array2 [k] = root;
}
for (k= 0; k < array3.length; k++) {
array3 [k] = (array2[k] - array2[k + 1]);
{
//while (k + 1) = %6 {
//System.out.print( df1.format(array3[k]));
res+=df1.format(array3[k]) + "\t";
if((k+1)%6==0)
res += "\n";
}
}
System.out.println(res);
System.in.read();
}
}