I'm creating an arithmetic calculator and need to be able to have it answer a question like (5.0+8.1)x(2.0) so far i have create my subclasses according to each mathematical operation i.e. +,-,x,/. I have got it to work for 2 numbers like 2.0 + 5.0 but i do not understand how i can get it to work for the above expression.
class Addition extends ArithmeticExpression{
Addition(double value1, double value2){
result = value1 + value2;
this.value1 = value1;
this.value2 = value2;
}
public double display() {
System.out.println("Addition Question Is");
System.out.println(value1 + " + "+ value2);
return result;
}
public double evaluate(){
System.out.println("Addition Answer Is");
System.out.println(result);
return result;
}
}