Welcome, guest! Login / Register - Why register?
[email protected] webmail now available. Want one? Go here.
Windows getting boring or just want to try something Open Source for your next Desktop Environment?! Go Zorin OS.

Paste

Pasted as C# by registered user AntonisPlatis ( 2 years ago )
using System;
using System.Threading;
namespace Time_table
{
    internal class Program
    {
        public static void Main()
        {
            int x, a, z, j;
            Console.Write("\n\n");
            Console.Write("Times table Console App\n");
            Console.Write("-----------------------");
            Console.Write("\n\n");
            //does this to catch any exeptions and exit if it does
            try
            {
                Console.Write("Give a number to calculate the times-table: ");
                x = Convert.ToInt32(Console.ReadLine());
                Console.Write("\n");
                Console.Write("Define the start point of the times-table: ");
                a = Convert.ToInt32(Console.ReadLine());
                Console.Write("\n");
                Console.Write("Define the end point of the times-table: ");
                z = Convert.ToInt32(Console.ReadLine());
                Console.Write("\n");
                if (a <= z)
                {
                    //clears to make it better looking
                    Console.Clear();
                    Console.Write("This is the times-table for number ({0}), with starting point number ({1}), and ending point number ({2})\n", x, a, z);
                    for (j = a; j <= z; j++)
                    {
                        Console.Write(" {0} * {1} = {2}\n", j, x, j * x);
                    }
                    Console.WriteLine("\n\nPress Enter to exit...");
                    Console.ReadLine();
                }
                else
                {
                    //clears to make it better looking
                    Console.Clear();
                    Console.Write("End point number cannot be less than the start point number\n ");
                    Thread.Sleep(3000);
                    Environment.Exit(0);
                }
            }
            catch (Exception)
            {
                //only shows if an exception occurs
                Console.Clear();
                Console.WriteLine("Exeption Detected, Are you using letters?");
                Thread.Sleep(3000);
                Environment.Exit(0);
            }
 
        }
    }
}

 

Revise this Paste

Your Name: Code Language: