JAVA Program to find the root of any integer using Newton Rapson Method.

package mathematicscomplexity;

import java.util.Scanner;

/**
 *
 * @author drcodeskm
 */
public class newtonRapsonMethod {
public static void main (String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
        double N;
        double ai=0;
        double xk;

        System.out.println("Type the integer whose square root you would like to compute: ");
        N = keyboard.nextDouble();
        xk = N;
        do{
                ai = ((xk + N / xk) / 2.0);
                xk = ai;
                                 System.out.println(ai);
       
        }while(Math.abs(ai - xk) < 0.0000001);
              

    }
}

0 comments:

Feel free to contact the admin for any suggestions and help.