Basic Square root program
<p>I'm trying to write a program that calculates the square root of a number using the ancient Babylonian averaging method. The goal of the program is to display the number the user entered, the value of the averaging method, the value using the math package, and the difference between the averaging method and the math package. The only problem I am encountering is that the output of the difference comes out to 0.000. Could someone please help me get the actual difference between both methods. Here is my code for the program :  </p>

<pre><code>import java.util.*;
public class SquareRoot
{
    static Scanner console = new Scanner(System.in);
    public static void main(String[] args)
    {
        int k;  
        double number;
        double number2; 
        double generator ;
        double Difference; 

        generator = (int)(Math.random() * 20 + 1); // generates a random number between '1' and '20' 

////////////////////////Take input from the user/////////////////////////////////////////////////////        
        System.out.print("Please enter the number that you want to take the square root of: ");
        number = console.nextDouble();


 //////////////////////////generate the square root using the averaging method///////////////////////       
        for( k = 1; k &lt;= 10; k++ )
        {
            generator = ( generator + (number/generator)) / 2;
        }    

////////////////////////Place the math package value in 'number2' and take the difference of the////// 
/////////////////////// averaged value and the true math package value//////////////////////////////// 
        number2 = Math.sqrt(number);

        Difference = (number2 - generator);

///////////////////////////////Display the results to the user////////////////////////////////////////       
        System.out.println("\nNumber    SquareRoot  MathPackage Difference");
        System.out.printf("%-6.3f    %-10.3f  ", number, generator);
        System.out.printf("%-11.3f %-10.3f%n" , number2 , Difference);




    }
}
</code></pre>