import javax.swing.*; public class Heron { public static void main (String[] args) { String input = JOptionPane.showInputDialog("Please enter a number"); double x = Double.parseDouble(input); double a = 1; final double EPSILON = 0.0000001; while (Math.abs(a*a - x)/x > EPSILON) { a = (a + x/a) / 2; } JOptionPane.showMessageDialog(null, "The square root of " + input + " is " + a); } }