[20160704]Addition program that use JOptionPane for input and output

时间:2024-01-20 23:16:51
 //Addition program that use JOptionPane for input and output.

 import javax.swing.JOptionPane;

 public class Addition{
public static void main(String[] args) {
String firstNumber=JOptionPane.showInputDialog("Enter first integer!"); String secondNumber=JOptionPane.showInputDialog("Enter second integer!"); int num1=Integer.parseInt(firstNumber);
int num2=Integer.parseInt(secondNumber); int sum=num1+num2; JOptionPane.showMessageDialog(null,"The sum is:\t"+sum,"sum of two integers",JOptionPane.PLAIN_MESSAGE); }
}