/* This calculates the factorial of a given integer
 * result = number!
 *        = 1 * 2 * 3 * ... * number
 */

import java.io.*;

class FactorialEnhanced  {
   // Some variables
   int inNumber;
   long outNumber;

   FactorialEnhanced(int arg) {
      // this is the constructor
      inNumber = arg;
      if (inNumber > 0)
        calculate();
   }

   void calculate () {
      // this "really" calculates the result
      outNumber = 1;	// initialize the outNumber
      for ( int j = 1; j <= inNumber; j++ )
         outNumber *= j;
   }

   long getResult () {
      // this gives back the calculated result
      return outNumber;
   }


   public static void main(String [] args) {
      // at first we declare some variables
      int number = 0;		// the input number

      // Read a integer number from user
      System.out.print("Please enter a number: ");
      try {
         number = (new Integer(new BufferedReader(new InputStreamReader(System.in)).readLine())).intValue();
      }
      catch (Exception e) {
         System.out.println(e.getMessage());
      }

      // Instanciate an instance of the calculator class
      FactorialEnhanced facCalculator = new FactorialEnhanced(number);

      // printout the result
      System.out.println("The factorial of " + number + " is " + facCalculator.getResult());

    }
}
