JAVA - How To Use JOptionPane.showInputDialog In Java NetBeans

How To Use JOptionPane.showInputDialog In Java

__________________________________________________________________

package JavaDB_001;
import javax.swing.*;

public class Project {

public static void main(String[] args){
    
 String num1,num2;
 int sum;
//get the first number fom showInputDialog
 num1 = JOptionPane.showInputDialog("Enter The First Number");
//get the Seconde number fom showInputDialog
 num2 = JOptionPane.showInputDialog("Enter The Seconde Number");

//verify the inout is not null
 if(num1 == null){
     num1 = "0";
 }
  if(num2 == null){
     num2 = "0";
 }

     sum = Integer.parseInt(num1) + Integer.parseInt(num2);

 JOptionPane.showMessageDialog(null, "The Sum Of this Two Number Is: "+sum);
 System.exit(0);
}
}




Share this

Related Posts

Previous
Next Post »