import javax.swing.JOptionPane; public class inputInteger { public static void main(String args[]) { // declare the result //int result; // Prompt the user to enter a number: String numString = JOptionPane.showInputDialog(null, "Enter a number from 1 to 10:", "Input Window Demo", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value int num = Integer.parseInt(numString); int result = num * num ; // Display the result in a message dialog box JOptionPane.showMessageDialog(null, num + " squared is " + result, "Input Window Demo", JOptionPane.INFORMATION_MESSAGE); System.out.println(num+" squared is " + result); System.exit(0); } }