Wednesday, July 19, 2017

Square Root Program

/*
A program that displays the square root of a number.
Created by Eyasu Mulugeta A.K.A BlackDiamond0014 on 6/23/2017.
eyasu@india.com
*/
import java.util.Scanner;

import static java.lang.Math.sqrt;

public class SquareRoots {
    public static void main(String[] args) {
        //we used the Scanner class to create an object to input data        
        Scanner in = new Scanner(System.in);
        int num=0;

        System.out.print("Please input a number : ");
        num = in.nextInt();

        System.out.println("The square root of "+num+" is "+sqrt(num));

    }
}
Share: