mirror of
https://bitbucket.org/Mattrixwv/javatutorials.git
synced 2025-12-06 10:33:57 -05:00
Added a program that generates popup boxes
This commit is contained in:
26
PopUp.java
Normal file
26
PopUp.java
Normal 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:
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user