I have the following code….
double num1 = Double.parseDouble(textArea_price.getText());
double num2 = Double.parseDouble(textArea_quantity.getText());
double result = num1*num2;
textArea_result.setText(
new BigDecimal(textArea_price.getText())
.multiply(new BigDecimal(textArea_quantity.getText())).toString());
Everytime a button is clicked the numbers in textArea_price and textArea_quantity is multiplied and displayed in textArea_result. I want the value in textArea_result to be added onto the result of the multiplication of the two textareas rather than resetting the value in textArea_result every time the button is clicked…
I don’t know Java but wouldn’t it be this?
If you really want to avoid if statements try this, but it is just syntactical sugar: