I am doing some GUI and I use JCheckBox
. I am wondering if this all can be do in an array and loop? It's so tiring to change every single thing.
If you can help me I'd love to hear.
if (box1.isSelected())
k = 40;
if (box2.isSelected())
l = 30;
if (box3.isSelected())
m = 20;
if (box4.isSelected())
n = 10;
if (box5.isSelected())
o = 10;
if (box6.isSelected())
p = 10;
if (box7.isSelected())
q = 10;
if (box8.isSelected())
r = 10;
if (box9.isSelected())
j = 10;
if (box10.isSelected())
i =10;
s = "Price for this is RM" +
(k + l + m + n + o + p + q + r + j + i);
JOptionPane.showMessageDialog(null, s);