When I had to solve this problem, I created a dictionary with hard-coded data to match numbers and related words. For example, the following number may represent several entries in a dictionary:
{1, "one"} {2, "two"} {30, "thirty"}
You really only need to worry about matching numbers at positions 10 ^ 0 (1,2,3, etc.) and 10 ^ 1 (10,20,30), because as soon as you get to 100, you just need to know when to use words like hundreds, thousand, a million, etc. combined with your card. For example, if you have a number, for example, 3240123, you get: three million two hundred forty thousand one hundred twenty three .
After you build your card, you need to work through each digit in your number and determine the appropriate nomenclature to go with it.
Ben McCormack Apr 28 '10 at 13:41
source share