Find Square Root Of Number - Java Quiz Question


Write a program to find the square root of a given number. If the given number is not a perfect square then return -1.

Input (Integer) Output (Integer)
1 1
2 -1
9 3
15 -1
625 25



class SquareRootOfNumber
{
    public static void main(String s[])
    {
        System.out.println("Square root of number 25 is " + squareRootOfNumber(25));

    }


    public static int squareRootOfNumber(int input)
    {
        int result;
        return result;
    }

}