Tuesday, February 2, 2016

Adding two number via dialog box in Java

import javax.swing.JOptionPane;

public class javaAdd{

public static void main(String args[]){

String a,b;

a = JOptionPane.showInputDialog("Enter first number:");
b = JOptionPane.showInputDialog("Enter second number:");

int sum=  Integer.parseInt(a) + Integer.parseInt(b);

JOptionPane.showMessageDialog(null,"Sum is "+sum,"Result",JOptionPane.PLAIN_MESSAGE);

}

}

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)