import javax.swing.*; public class SampleInputDialog { public static void main(String[] args) { String s1,s2,message; double num1,num2,average; s1 = JOptionPane.showInputDialog("Enter a number:"); s2 = JOptionPane.showInputDialog("Great! Now enter a second number:"); num1 = Double.parseDouble(s1); num2 = Double.parseDouble(s2); average = (num1 + num2)/2.0; message = "The average of " + num1 + " and " + num2 + " is " + average; //send output to the terminal window System.out.println(message); //send output to a MessageDialog box JOptionPane.showMessageDialog(null,message,"SampleDialog", JOptionPane.INFORMATION_MESSAGE); } }