Java Program To Find Square Root of A Number - Java Programming Interview Questions @Fresher-Naukri.com

Java Programming Interview Questions


Java Program TO Find Square Root Of A Number


package test;
import java.util.Scanner;

public class Squareroot {

        public static void main(String args[ ] )   {

        Scanner scanner = new scanner (system.in);

        System.out.println("Enter number to find square root in java : ");

        double square = Scanner.nextDouble( );

        double squareRoot = Math.sqrt(square);

        System.out.printf("Square root of number:  %f  is : %f %n" , square, squareRoot);

    }

}


Output:
Enter number to find square root in java :
64
The square root of a number:  64,000000 is: 8,000000

0 comments 10:

Post a Comment