Tuesday, February 11, 2014

Example of addition using Swing JOptionPane.

import javax.swing.JOptionPane;

class SwingAddition
{
public static void main(String surat[])
{
String s1=JOptionPane.showInputDialog("Enter First Number");
String s2=JOptionPane.showInputDialog("Enter Second Number");

int n1=Integer.parseInt(s1);
int n2=Integer.parseInt(s2);

int sum=n1+n2;

JOptionPane.showMessageDialog(null,"The sum is " + sum,"Addition", JOptionPane.PLAIN_MESSAGE );
}
}

Output:

No comments:

Post a Comment