Monday, August 13, 2012

JOptionPane - showInputDialog


import javax.swing.*;


class AdditionDemo{
public static void main(String rk[]){


try{
String num1 = JOptionPane.showInputDialog("Input fist Value") ;
String num2 = JOptionPane.showInputDialog("Input second Value") ;

int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
int c = a+b;
JOptionPane.showMessageDialog(null," Total is : "+c);

}catch(Exception e ){
JOptionPane.showMessageDialog(null,"Oop !! Buddy, you gave wrong input. :-( ");
}
}
}

No comments:

Post a Comment