I'm assuming your code contains the following statements:
Scanner userIn = new Scanner(System.in);
//userIn.next() somewhere in your code, which is what you want to test
You could use the following method (pass userIn.next() as an argument):
public boolean isDouble(String userInput){
if(userInput.contains(".")){
return true;
}
else{
return false;
}
}
This code basically checks if the userInput String contains a decimal point, if so the input is a double else it would be a false, you could also add preliminary conditions to make sure that the userInput is a number and not anything else.
EDIT:
As Klitos Kyriacou has rightfully pointed out in the comments, my answer did not initially answer the question asked, however the OP was satisfied... for the sake of completeness, I will answer the question specifically:
The sqrt method from the static class Math returns a double, so using the test above will not work as Math.sqrt(25) will return 5.0.
To go about this one can simply compare the rounded value of the sqrt's return value to the actual return value of the sqrt method.
You could use the following method (As in the case above userIn.next(), will be the argument to the method):
public boolean isPerfectSquare(String userInput){
if(Math.sqrt(Double.parseDouble(userInput)) == Math.round(Math.sqrt(Double.parseDouble(userInput)))){
return true;
}
return false;
}