Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C# by registered user AntonisPlatis ( 4 years ago )
//Problem Solving with Programming
//Coursework 1
//Antonis Platis 12/3/2020
using System; //library for Console.
using System.Threading; //library for thread.
namespace Times_table
{
internal static 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");
try //exception monitoring block
{
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)
{
Console.Clear(); //clears to make it better looking
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++) //main loop
{
Console.Write(" {0} * {1} = {2}\n", j, x, j * x);
}
Console.WriteLine("\n\nPress Enter to exit...");
Console.ReadLine();
}
else
{
Console.Clear(); //clears to make it better looking
Console.Write("End point number cannot be less than the start point number\n ");
Thread.Sleep(3000); //delay 3000 milliseconds
Environment.Exit(0);
}
}
catch (Exception) //exception handling
{
//only shows if an exception occurs
Console.Clear();
Console.WriteLine("Exception Detected, Are you using letters?");
Thread.Sleep(3000); //delay 3000 milliseconds
Environment.Exit(0);
}
}
}
}
Revise this Paste