I'm having trouble with my while loop in the sqrt method. Any ideas on how to make it work?

thanks in advance!!

//Program requirements: user inputs a number and the program outputs a square root. /*Program design: Calculators work by using the Newton's Method or Babylonian method by tral and error. You begin with variable root x and a starting x0. Then the average of the over estimate and the underestimate will eual an approximation close to the square root. If you repeat the proccess with the new approximation you get an even closer value. If the process is repeated, eventually you will get within a certain accuracy.*/ // Calculators only have 8 decimall places, so I'll go to 8 points of accuracy. //^^/> this is my own thinking, not real instructions. import java.util.Scanner; public class SquareRoot { public static void main (String[] args) { Scanner scan = new Scanner(System.in); Sqrt ans = new Sqrt(); System.out.println("Please enter your number."); double num = scan.nextDouble(); System.out.println(ans.sqrt(num)); } }

import java.util.Scanner; import java.lang.Math; public class Sqrt { public double sqrt(double num) { double x = 1; double y=1; while(Math.abs(x-y) < 0.00001) { y=x; x = 0.5*(x + num/ x); } return x; } }import java.util.Scanner; import java.lang.Math; public class Sqrt { public double sqrt(double num) { double x = 1; double y=1; while(Math.abs(x-y) < 0.00001) { y=x; x = 0.5*(x + num/ x); } return x; } }