Hello,

can someone help me with this code (it is a calculator with ActionListener):
Code:
else if (src == referenca.buttonPlus)//when someone press button +
{
num=referenca.getDisplay();//gets the number that someone typed and saves it into variable num
numStringToDouble = Double.parseDouble(num);//Converts String to Double
matOperacija="+"; //saves mathematical operations - I have set this variable to be INT but I am not sure what should it be INT,CHAR,STRING...
referenca.setDisplay ("",""); //sets blank display
}
//the same as buttonPlus
else if (src == referenca.buttonMinus)
{
num = referenca.getDisplay();
numStringToDouble = Double.parseDouble(num);
matOperacija="-";
referenca.setDisplay("","");
}
else if (src == referenca.buttonEqual)
{
String equal= referenca.getDisplay();//gets displayed number
Double newEqual =Double.parseDouble(equal);//converts displayed number into double
Double result = //here is where I should use a mathematical operation but I do not know how.
String newResult = Double.toString(result); // converts Double into String
referenca.setDisplay(newResult);//sets display to a new result
}
My problem is that I do not know how to do this: When I type first number and a mathematical operation that number is saved into variable numStringToDouble and so is mathematical operation saved into matOperacija (not sure what type should I use int or String or Char) and then when I type number two and press equal number on the display should be added, multiplyed etc. whit the number saved in a variable numStringToDouble. My biggest problem is that I do not know how to deal with mathematical operations. How to save them and how to use them.
