Program:
package java_tutorial_1;
import javax.swing.JOptionPane;
public class gui {
public static void main(String[] args){
String fn=JOptionPane.showInputDialog("Enter first number: ");
String sn=JOptionPane.showInputDialog("Enter second number: ");
int num1=Integer.parseInt(fn);
int num2=Integer.parseInt(sn);
int res=num1+num2;
JOptionPane.showMessageDialog(null,"answer "+ res,"title", JOptionPane.PLAIN_MESSAGE);
}
}
package java_tutorial_1;
import javax.swing.JOptionPane;
public class gui {
public static void main(String[] args){
String fn=JOptionPane.showInputDialog("Enter first number: ");
String sn=JOptionPane.showInputDialog("Enter second number: ");
int num1=Integer.parseInt(fn);
int num2=Integer.parseInt(sn);
int res=num1+num2;
JOptionPane.showMessageDialog(null,"answer "+ res,"title", JOptionPane.PLAIN_MESSAGE);
}
}
Screenshots
Program
Output 1
Output 2
Output 3
No comments:
Post a Comment