Turning numbers into words

Hello. Sorry in advance for the stupid and long java question.

I want to write a java program that will turn any number of up to 9 digits in length into the correct englsh words for that number. So if the user inputs 1234, the program will respond with: one thousand two hundred and thirty four. Or if the user inputs 7231560, the program responds with: seven million, two hundred and thrity one thousand, five hundred and sixty. The caveats: the number can be of any length from 1 to 999999999, and doesn't include any commas or other delimiters.

I have successfully written a program that will do this for any number of three digits in length. I then re-wrote the program (posted below) to write a special method to do this conversion of any three digits into the proper words. I was thinking that once I had this special method, it should be easy for me to apply the three digit method to larger numbers. BUT, to apply the three digit method to a larger number, I have to split up the larger number into groups of 3, but in reverse order (so 7231560 becomes 560, 231, and 7, and not 723, 156, and zero).

SO - my question: how do I split up a number of unknown length into groups of 3 from back to front? Also - my approach of applying my three digit method to a larger number may not be the best approach to accomplish the overall task of turning a number into words. Is there a better way to do this?

Here, the program I wrote that turns any three digit number into the proper english words.

Re: Turning numbers into words

Thank you Kevin for your useful suggestion. I will take a look.

I think I might have solved the problem in a different fashion. It just occurred to me that if I have a number n, I can do n%1000 to give me the last three digits in their right order, no matter what the original length of n. Then (n/1000)%1000 will give me the next three digits again in proper order. I'm going to go play around with my program some more and see if I can make it work.

Re: Turning numbers into words

Suppose you have a number bmmmtttuuu; if b isn't zero you pronounce it as b billiard etc. if mmm isn't zero you pronounce further as mmm million etc. the same goes for ttt thousand etc. all you have to do is write a method that can pronounce a number up to 999.