|
This looks like homework to me, but basically all you need is a lookup table containing strings. You'll need unique strings for 'zero' through 'nineteen', as well as the tens values ('twenty', 'thirty', etc). Then you'll need magnitude strings, such as 'hundred', 'thousand', 'million', and so on. If the number is an integer, that's about it, but if it's floating-point, you'll need 'point' in your lookup table.
From these, you can build up whatever number you want, assuming you don't exceed your maximum magnitude. You might also consider adding in 'and' where applicable. Though it's technically not correct usage, many people will say 'eight hundred and seventeen' rather than 'eight hundred seventeen'.
Final hint: the division and modulus operators are your friends for this endeavor.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
|