Follow the steps to create GUI:
Addition using Input Dialog Box
Step-1: Drag and drop four radio buttons for Add, Subtract, Multiply and Divide.
Step-2: Change the variable name of Add Radio Button to AddRadioButton.
Step-3: Double Click on Add Radio Button.
Step-4: Write the following code:
private void AddRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
double fn=Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
double sn=Double.parseDouble(JOptionPane.showInputDialog("Enter Second Number"));
double sum=fn+sn;
JOptionPane.showMessageDialog(null, sum);
}
Similarly for other operations like Subtraction, Multiplication, and Division.
No comments:
Post a Comment
If you have any doubt, please leave a comment