// calculating factorials using a method import javax.swing.JOptionPane; public class Factorials { public static void main( String[] args ) { int number, index; // int result = 1; String numString1 = JOptionPane.showInputDialog(null, "Enter an integer from 2 - 16 ", "Input Number Window", JOptionPane.QUESTION_MESSAGE); number = Integer.parseInt(numString1); if (number > 1 && number < 17) { System.out.println("The factorial of "+number+" is " + factorialMethod(number)); } // end if number > 1 ... else { System.out.println(number + " is not a valid number for this computation."); } System.exit( 0 ); } // end main public static int factorialMethod (int x ) { int result = 1; for (int counter = 1; counter <= x; counter ++) { result = result * counter; } // end of for index return result; } // end of factorialMethod } // end of program