Start by writing your program so that it simply substitutes "one" for 1 and "two" for 2 so that in your case it will output one two three four. Then improve the code to produce "thirty four" instead of "three four". You will need to take care of "eleven" to "nineteen" with the tens and ones digits and then extend this out for use with "fourteen" billion, million, thousand and hundred.
hth`s