Connect with one of the following accounts


Please wait while we redirect...

Views: 160   

Following program shows you how to take a number as input and calculate the square root of given number.
In this program we get input from user and calculate square root using Math.sqrt() method

import java.util.Scanner;

public class BasicMath9 {

    public static void main(String[] args) {

        System.out.println("Enter a number:");

        double input;

        Scanner in = new Scanner(;
        input = in.nextFloat();

        double result = Math.sqrt(input);

        System.out.println("Input: " + input);
        System.out.println("Square root of " + input + " is: " + result);




Enter a number:
Input: 64.0
Square root of 64.0 is: 8.0

On By

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News