kitsune
Dec 10th, 2003, 10:36 AM
I'm working on a calculator applet. When I try to divide by 0 (like, 1/0), I want it to output a message (like, "You cannot divide by 0"). At the moment, if I try to divide by 0, it outputs "Infinity". Here's my code:
class DivOperation extends MathOperation
{
public double operate(double operand1, double operand2)
{
return operand1 / operand2;
}
}
Since the return type of the method is double, it won't let me return a String filled with the message. Any idea how I could do this?
class DivOperation extends MathOperation
{
public double operate(double operand1, double operand2)
{
return operand1 / operand2;
}
}
Since the return type of the method is double, it won't let me return a String filled with the message. Any idea how I could do this?