Convert Digits to Words in Java

Posted on in: All Posts, My Projects.

The other day while I was tutoring a student in java, we came upon a problem I found intriguing. One of the student’s problems was to convert digits to words. For example, to convert “$35.54” which is “3554” cents to “THIRTY FIVE DOLLARS AND FIFTY FOUR CENTS”. However the student only had to convert amounts from zero to one million. They also didn’t need to account for numbers such as “000567”, or “500000”, or “0000” or empty strings “”. I found this problem intriguing enough that I wanted to be able to do this for any amount from zero to some massively high number… say 999 NOVEMDECILLION (999×10^60) and account for all of those outlying cases. Although the only reason I would think someone might be interested in such a java class would be for text to speech applications, if you are interested you can check out my Bitbucket Repo.