Write the definition of a class named SQRTException whose objects are created by specifying the original negative value that caused the problem in the first place: new SQRTException(originalArgument).

LANGUAGE: JAVA

CHALLENGE:

The argument to a square root method (sqrt) in general should not be negative. Write the definition of a class named SQRTException whose objects are created by specifying the original negative value that caused the problem in the first place: new SQRTException(originalArgument).

The associated message for this Exception should be “Bad argument to sqrt: ” followed by the value specified at the time of instantiation .

SOLUTION:

public class SQRTException extends Exception{
    public SQRTException(double badvalue){
        super("Bad argument to sqrt: " + badvalue);
    }
}