Advertisement
makispaiktis

3. Swing Example

May 15th, 2022 (edited)
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class SwingExample {
  4.  
  5.     public static void main(String args[]){
  6.         String n1 = JOptionPane.showInputDialog("1st number: ");
  7.         String n2 = JOptionPane.showInputDialog("2nd number: ");
  8.         int n11 = Integer.parseInt(n1);
  9.         int n22 = Integer.parseInt(n2);
  10.         int n = n11 + n22;
  11.         JOptionPane.showMessageDialog(null, "The sum is " + n, "Adding two numbers", JOptionPane.PLAIN_MESSAGE);
  12.     }
  13. }
  14.  
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement