在这个程序中,如果条件是选中两个复选框时,我无法满足第三个其他条件。它仍然显示40%的价格,而它应显示50%。
int p = Integer.parseInt(jTextField1.getText()); //Product Price
int dis = 40*p/100; // 40% discount
int adis = 10*p/100; // 10% discount
int tdis = 50*p/100; // 50% discount
int fpd = p-dis; // final price (40% discount)
int fpad = p-adis; // final price (10% discount)
int fptdis = p-tdis; // final price (50% discount)
if (jCheckBox1.isSelected()==true)
jLabel3.setText("dis is 40% "+"dis amt is "+dis+"final price is "+fpd);
else if (jCheckBox2.isSelected()==true)
jLabel3.setText("dis is 10% "+"dis amt is "+adis+"final price is "+fpad);
// This condition is not working!!
else if (jCheckBox1.isSelected()==true && jCheckBox2.isSelected()==true)
jLabel3.setText("dis is 50% "+"dis amt is "+tdis+"final price is "+fptdis);
else jLabel3.setText("no discount"+"final price is "+p);