Beispiel #1
0
 static void Main(string[] args)
 {
     int number;
     Factorial obj = new Factorial(); // object of class Factorial
     System.Console.WriteLine("FACTORIAL CALCULATION\n");
     try
     {
         System.Console.Write("Enter the number: ");
         number = Convert.ToInt32(System.Console.ReadLine());
         System.Console.WriteLine("Factorial of {0} is: {1}", number, obj.CalculateFactorial(number));
     }
     catch (FormatException e)
     {
         System.Console.WriteLine("You can enter numeric values only. Exiting...");
     }
     System.Console.ReadLine();
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            int       number;
            Factorial obj = new Factorial(); // object of class Factorial

            System.Console.WriteLine("FACTORIAL CALCULATION\n");
            try
            {
                System.Console.Write("Enter the number: ");
                number = Convert.ToInt32(System.Console.ReadLine());
                System.Console.WriteLine("Factorial of {0} is: {1}", number, obj.CalculateFactorial(number));
            }
            catch (FormatException e)
            {
                System.Console.WriteLine("You can enter numeric values only. Exiting...");
            }
            System.Console.ReadLine();
        }