Using Dialog Boxes for Input and Output
import javax.swing.JOptionPane; public class UserInterface { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter your name:"); JOptionPane.showMessageDialog(null, "Nice to meet you, " + input); System.exit(0); } }
import javax.swing.JOptionPane; public class UserInterface { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter price:"); double price = Double.parseDouble(input); JOptionPane.showMessageDialog(null, "Price: " + price); System.exit(0); } }
import javax.swing.JOptionPane; public class UserInterface { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter the first integer:"); int num1 = Integer.parseInt(input); String input1 = JOptionPane.showInputDialog("Enter the second integer:"); int num2 = Integer.parseInt(input1); JOptionPane.showMessageDialog(null, num1 + " + " + num2 + " = " + (num1+num2)); System.exit(0); } }
Can you modify the above file to display the following information?