Convert a Number to Text

This class takes a number and converts it to the equivalent text in English.

For example, the input 1 should return the string “one” and 123,456 should return the string “one hundred twenty three thousand four hundred fifty six.” (The program does not try to insert the word “and” between any of the numbers.)

The class has one constructor, which takes the integer to convert as a parameter, and has a single method—getString()—that returns the string. This is not necessarily the ideal interface for such a class, but it works for these purposes.

The constructor uses the pow() method from the Math package, which raises a number ...

Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.