using System;
namespace ValueToWord
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(NumberToWord(2340567));
Console.Read();
}
public static string NumberToWord(int Value)
{
if (Value == 0)
return "zero";
if (Value < 0)
return "minus " + NumberToWord(Math.Abs(Value));
string Output = "";
if ((Value / 1000000) > 0)
{
Output += NumberToWord(Value / 1000000) + " million ";
Value %= 1000000;
}
if ((Value / 1000) > 0)
{
Output += NumberToWord(Value / 1000) + " thousand ";
Value %= 1000;
}
if ((Value / 100) > 0)
{
Output += NumberToWord(Value / 100) + " hundred ";
Value %= 100;
}
if (Value > 0)
{
if (Output != "")
Output += "and ";
dynamic WordList1 = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
dynamic WordList2 = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
if (Value < 20)
Output += WordList1[Value];
else
{
Output += WordList2[Value / 10];
if ((Value % 10) > 0)
Output += "-" + WordList1[Value % 10];
}
}
return Output;
}
}
}