You are on page 1of 1

b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ int a=Integer.parseInt(txt1.getText()); int b=Integer.parseInt(txt2.getText()); if(r1.isSelected()==true){ int c=a+b; lbl2.setText(String.

valueOf(c)); }else if(r2.isSelected()==true){ int c=a-b; lbl2.setText(String.valueOf(c)); }else if(r3.isSelected()==true){ int c=a*b; lbl2.setText(String.valueOf(c)); }else if(r4.isSelected()==true){ int c=a/b; lbl2.setText(String.valueOf(c)); }else{ JOptionPane.showMessageDialog(null, "Sorry", "No Option" , JOptionPane.PLAIN_MESSAGE); } } });

You might also like