Java: Input using Swing GUI and add numbers

 

 

 

 

Here is the AddNumGUI.java source code

import static java.lang.System.out;import javax.swing.JOptionPane;
public class AddNumGUI {
  
  
  public static void main(String[] args) { 
     int num1 = Integer.parseInt(JOptionPane.showInputDialog("First Number:"));
     int num2 = Integer.parseInt(JOptionPane.showInputDialog("Second Number:"));
     
     int result = num1 + num2;
       
     JOptionPane.showMessageDialog(null, "The result is "+result); 
  }
}