So Basically I am creating this pizza program and on one page I have a section where people can choose a list of toppings. Now each topping is 1.50 and as soon as they click a topping a sidebar on my gui would display the price. Now I have 12 toppings radio buttons but the problem arises when I click 2 radio buttons it just displays the price 1.50.
I just want to know if there's a way to add 1.50 to my jLabel on my sidebar every time I press a topping button and when I deselect a topping it would subtract 1.50 from the jLabel so the price is accurate.
Here is my code I have done til now
Pepperoni Radio Button final String LastMoney = ToppingsPriceL.getText(); final double LM = Double.parseDouble (ToppingsPriceL.getText()); String PBtn = PepperoniBtn.getText(); boolean PepperoniBtn; PepperoniBtn = true; if (PepperoniBtn) { ToppingsDisplayL.setText(PBtn); ToppingsPriceL.setText(Money.format(1.50 + LM)); } } Green Olive Radio Button final String LastMoney = ToppingsPriceL.getText(); final double LM = Double.parseDouble (ToppingsPriceL.getText()); String GObtn = GreenOlivesBtn.getText(); boolean GreenOlivesBtn; GreenOlivesBtn=true; if (GreenOlivesBtn) { ToppingsDisplayL.setText(GObtn); ToppingsPriceL.setText(Money.format(1.50 + LM)); }