Ok, well what specifically about the if/else statement is confusing? What are you needing to do?
In JAVA, we have a very rich API. One notable class is the Math Class(
Math (Java Platform SE 6)).
In the Math Class, there is the following method:
sqrt
public static double sqrt(double a)
Returns the correctly rounded positive square root of a double value. Special cases:
* If the argument is NaN or less than zero, then the result is NaN.
* If the argument is positive infinity, then the result is positive infinity.
* If the argument is positive zero or negative zero, then the result is the same as the argument.
Otherwise, the result is the double value closest to the true mathematical square root of the argument value.
Parameters:
a - a value.
Returns:
the positive square root of a. If the argument is NaN or less than zero, the result is NaN.
Does that make sense?