public class Calculator {
private int operand1;
private int operand2;
private char operator1;
private double result;
public double calculate(char op, int num1, int num2)
{
operand1=num1;
operand2=num2;
operator1=op;
switch(op)
{
case '+':
addition();
break;
case '-':
subtraction();
break;
case '*':
multiplication();
break;
case '/':
division();
break;
}
return result;
}
public void addition()
{
result=operand1+operand2;
}
public void subtraction()
{
result=operand1-operand2;
}
public void multiplication()
{
result=operand1*operand2;
}
public void division()
{
result=operand1/operand2;
}
}