The program supports both the US and UK numbering systems. For example the number 620 would be expressed as follows:
Six Hundred Twenty (in the US system)
Source Code
using System;
class Program
{
static void Main()
{
string input;
int number;
bool isValid;
bool isUK = false;
Console.WriteLine("\nEnter '0' to quit the program at any time\n");
while (true)
{
Console.Write("\nUse UK numbering y/n : ");
input = Console.ReadLine();
if (!(input.ToLower() == "y" || input.ToLower() == "n"))
Console.WriteLine("\n Must be 'y' or 'n', please try again\n");
else
{
if (input.ToLower() == "y") isUK = true;
Console.WriteLine("\n");
break;
}
}
do
{
Console.Write("Enter integer : ");
input = Console.ReadLine();
isValid = int.TryParse(input, out number);
if (!isValid)
Console.WriteLine("\n Not an integer, please try again\n");
else
Console.WriteLine("\n {0}\n", NumberToText(number, isUK));
}
while (!(isValid && number == 0));
Console.WriteLine("\nProgram ended");
}
READ MORE>>
0 comments:
Post a Comment