Added a program that generates popup boxes

This commit is contained in:
2019-02-12 12:29:29 -05:00
parent 085e4de443
commit b6400bb145

26
PopUp.java Normal file
View File

@@ -0,0 +1,26 @@
//Java/JavaTutorials/PopUp.java
//Matthew Ellison
// Created: 02-12-19
//Modified: 02-12-19
//This is a simple tutorial on pop up boxes
import javax.swing.JOptionPane;
public class PopUp{
public static void main(String[] argv){
//Prompt the user to enter a string
String words = JOptionPane.showInputDialog("Enter a string to be printed");
JOptionPane.showMessageDialog(null, words);
//Prompt the user to enter 2 numbers and print their sum
words = JOptionPane.showInputDialog("Enter a number to be summed");
int num1 = Integer.parseInt(words);
words = JOptionPane.showInputDialog("Enter another number to be summed");
int num2 = Integer.parseInt(words);
JOptionPane.showMessageDialog(null, num1 + " + " + num2 + " = " + (num1 + num2));
}
}
/* Results:
*/