All pastes #468874 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-03 12:47 UTC
rendered paste body
/*
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

      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]));
                    
                   System.out.println( df1.format(array3[k]));
                    }
                }

	              System.in.read();

 }
}