Implementing this is not that difficult. Consider the following:
- You have to isolate, from the end, each set of 3 numbers. The same pattern is applied every three numbers, with the multiplicator between. i.e.:
253 billions 253 millions 253 thousands 253
So, what you gotta do is process each set of 3 numbers.
if there is 3, the first one will be "hundred".
for the second number, if it's >= 2, it will be twenty, thirty, ...
In fact, all you have to store is:
numbers from 0 to 19
prefixes (twenty, thirty)
multiplicators (thousand, million, billion, ...)
The use of array is, i believe, mandatory.
- So, first check for the first set (at left), that could be of 3 or less numbers)
- Then, if there is 3 numbers, the left one is the hundred
- Then, if the second number is >= 2, apply prefix and the last number
- Otherwise, check in the array for the number.
- Apply the multiplicator (million, billion)
- Continue until finished
And that's it.
I hope that helps, and good luck
S. Breton