Multiplication table

 using System;

using System.IO;

using System.Linq;

using System.Collections.Generic;

namespace CSharp_Shell

{

  public class Program

  {

 public static void Main()

 {

   test();

 }

 //Methods

 public static void MultiplicationTable(int num)

 {

   Console.ForegroundColor = ConsoleColor.Green;

   for (int i = 1; i < 11; i++)

   {

  int answer = num * i;

  Console.WriteLine("\t{0,2} × {1,2} = {2}", num, i, answer);

   }

   Console.ResetColor();

 }

 public static void test()

 {

   string input = "";

   Console.WriteLine("Multiplication Table");

   while (true)

   {

  Console.ResetColor();

  Console.Write("Enter a Number : ");

  int num = int.Parse(Console.ReadLine());

  MultiplicationTable(num);

  Console.WriteLine("Enter clr or con");

  Console.ForegroundColor = ConsoleColor.Red;

  Console.WriteLine("");

  input = Console.ReadLine();

  Console.WriteLine("");

  if (input == "clr")

  {

    Console.Clear();

  }

  else if (input == "con")

  {

  }

  else

  {

    break;

  }

   }

 }

  }

}


Comments

Popular Posts