Opération de deux nombres
bonjour ,
voici mon code pour faire (+, -, *, /) de deux nombres , ça me donne des erreurs.... de l'aide svp..
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (txt_nb1.getText().isEmpty() || txt_nb2.getText().isEmpty())
{
JOptionPane.showMessageDialog(null," saisissez les nombres");
}
String aa , bb ;
aa = txt_nb1.getText();
bb = txt_nb1.getText();
double a , b ,res;
a = Integer.parseInt(aa);
b = Integer.parseInt(bb);
res= Integer.parseInt(txt_res.getText());
String ress = String.valueOf(res);
if(jRadioAddition.isSelected())
{
// txt_res.setText((txt_nb1.getText()) + (txt_nb2.getText()));
txt_res.setText(ress);
res = a + b;
}
if(jRadioSoustra.isSelected())
{
txt_res.setText(ress);
res= a-b;
}
this.setDefaultCloseOperation(ex1_RB.DISPOSE_ON_CLOSE);
} |