in this tutorial, you can learn how to get the square root of a number in Java.
Make the object of Scanner class then take input from the keyboard, simply use math class and get a square of a number in Java
Example:
package javaapplication;
import java.util.Scanner;
public class JavaApplication {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter an integer number: ");
int num = sc.nextInt();
System.out.println("Square Root of " + num + " is: " + Math.sqrt(num));
}
}
output:
run:
Enter an integer number: 144
Square Root of 144 is: 12.0