// Program Name                  Factorials.java
// Course:                       CSE 1302J
// Student Name:                 Bradley Shedd
// Assignment Number:            Lab#7
// Due Date:                     10/20/2010
// Purpose:                      This program reads integers from the user
//                               and prints the factorial of each.

import java.util.Scanner;

public class Factorials
{
   
public static void main(String[] args)
    {
   String keepGoing =
"y";
   Scanner scan =
new Scanner(System.in);

  
while (keepGoing.equals("y") || keepGoing.equals("Y"))
       {
      
try
       {
      System.out.print(
"Enter an integer: ");
     
int val = scan.nextInt();
      System.out.println(
"Factorial(" + val + ") = "
               + MathUtils.factorial(val));
       }
      
catch (IllegalArgumentException iae)
       {
       System.out.println(iae.getMessage());
       }
      
      System.out.print(
"Another factorial? (y/n) ");
      keepGoing = scan.next();
       }
       System.out.println(
"Coded By: Bradley J. Shedd");
    }
}

Homepage