import javax.swing.JOptionPane; /** * User IO is a class that supports the retrieal of users input and output to the command line. */ public class UserIO { /** private constructor Userinput does not require to be an instance */ private UserIO() {} /** *Gets input from the user returns the result as a string */ public static String getStringFromUser(String question) { String userInput = ""; userInput = JOptionPane.showInputDialog( question ); return userInput; } /** *Gets input from the user returns the result as a string */ public static int getIntFromUser(String question) { String userinput = getStringFromUser(question); int result=-1; try { result = Integer.parseInt(userinput); } catch(NumberFormatException ex) { throw new NumberFormatException ("The number given was not a whole numeric value."); } return result; } }