Task

Show how to spell out a number in English.

You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less).

Support for inputs other than positive integers (like zero, negative integers, and floating-point numbers) is optional.



Related task

   Spelling of ordinal numbers.


Module Module1
 
    Sub Main()
        Dim i As Integer
        Console.WriteLine("Enter a number")
        i = Console.ReadLine()
        Console.WriteLine(words(i))
        Console.ReadLine()
    End Sub
 
    Function words(ByVal Number As Integer) As String
        Dim small() As String = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
         "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
         "eighteen", "nineteen"}
        Dim tens() As String = {"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"}
        Select Case Number
            Case Is < 20
                words = small(Number)
            Case 20 To 99
                words = tens(Number \ 10) + " " + small(Number Mod 10)
            Case 100 To 999
                words = small(Number \ 100) + " hundred " + IIf(((Number Mod 100) <> 0), "and ", "") + words(Number Mod 100)
            Case 1000
                words = "one thousand"
        End Select
    End Function
 
End Module