assume i have integer variables a,b and c.
c = a + b; or c = a - b; or c = a / b; or c = a * b;
As you can see, the computation operator needs to be passed dynamically at run time. So i have a jComboBox of operators, so a user will select either a +, -, * or / from the jcomboBox.
how do i get the jCombobox selectedItem(which will be either /, *, -, or + ) and use it in getting the value of c.
Eg. if the user selects *, then the expression should be c = a * b else if the user selected say +, then the expression should be c = a + b.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…