Class Factorial

java.lang.Object
  
public class Factorial
extends java.lang.Object

A class whose methods implement a recursive solution to factorials.

Version:
SCCC West - Copyright (c) 2009
Author:
Carl B. Struck

Constructor Summary
Factorial()
           
 
Method Summary
static int factorial(int n)
          A recursive method which calculates and returns the factorial of a positive integer or zero (0).
static void start()
          Gets an integer from the console, passes it to method factorial() and displays the resulting factorial to the console.
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factorial

public Factorial()
Method Detail

factorial

public static int factorial(int n)
                     throws java.lang.Exception
A recursive method which calculates and returns the factorial of a positive integer or zero (0).

Parameters:
n - an integer whose factorial is to be calculated
Returns:
The factorial of the input integer
Throws:
java.lang.Exception - thrown if parameter is a negative value

start

public static void start()
Gets an integer from the console, passes it to method factorial() and displays the resulting factorial to the console.

Throws:
java.util.InputMismatchException - if user enters non-integer input