java.lang.Object
public class Factorial
A class whose methods implement a recursive solution to factorials.
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 |
---|
public Factorial()
Method Detail |
---|
public static int factorial(int n) throws java.lang.Exception
n
- an integer whose factorial is to be calculated
java.lang.Exception
- thrown if parameter is a negative valuepublic static void start()
java.util.InputMismatchException
- if user enters non-integer input