/** Calculates the square root of any double using the Babylonian algorithm.
 * 
 */

package babylonianalgorithm;

/**
 *
 * @author k8port
 */
import java.text.DecimalFormat;
import java.util.Scanner;

public class BabylonianAlgorithm {

    /**
     * @param args the command line arguments
     */
  
    private static final double PERCENT = 0.01;  // percentage of accuracy for determining number of iterations
    
    public static void main(String[] args) {
        
        // declare variables
        double r, temp, guess;
        Scanner scan = new Scanner(System.in);
        DecimalFormat formatter = new DecimalFormat("000.00"); // for formatting ressults 
        
        // gather input from console
        System.out.println("Enter a number to calculate square root using "
                + "the babylonian algorithm.");
        int n = scan.nextInt();
        
        // calculate algorithm
        // repeat loop until result is within 1% of previous result
        guess = n / 2;
        do {
            temp = guess;
            System.out.println("iterate");
            r = n / guess;
            guess = (guess + r) / 2;
        } while ((temp - guess) >= (PERCENT * temp));
        
        System.out.println(formatter.format(guess));
        
    }
    
}

@@ -295,19 +295,16 @@
      */%0A
-  %0A
     priv
@@ -346,72 +346,8 @@
 .01;
-  // percentage of accuracy for determining number of iterations
 %0A   
@@ -417,14 +417,15 @@
  // 
-declar
+instanc
 e va
@@ -455,32 +455,74 @@
 r, temp, guess;%0A
+        int n = -1; // initialize n to -1%0A
         Scanner 
@@ -564,136 +564,73 @@
     
-DecimalFormat formatter = new DecimalFormat(%22000.00%22); // for formatting ressults %0A        %0A        // gather input from console
+%0A        // gather user input%0A        while (n %3C 1) %7B            
 %0A   
@@ -626,32 +626,36 @@
        %0A        
+    
 System.out.print
@@ -758,27 +758,27 @@
 %22);%0A        
-int
+   
  n = scan.ne
@@ -786,32 +786,34 @@
 tInt();%0A        
+%7D 
 %0A        // calc
@@ -809,98 +809,96 @@
     
-// calculate algorithm%0A        // repeat loop until result is within 1%25 of previous result
+DecimalFormat formatter = new DecimalFormat(%22000.00%22);%0A        %0A        // iteration one
 %0A   
@@ -959,32 +959,35 @@
 ess;%0A           
+ //
  System.out.prin

Update BabylonianAlgorithm.java