- Java 8+ (for streams)
- Apache Maven 3.8+
- Jetbrains Annotations 13+ (for @NotNull)
- JUnit 5+ (for parametric testing)
The easiest way to run Wordify is with the precompiled JAR. Make sure the Java executable is on the class path, then navigate to the lib/
folder. On Linux, run:
java -jar Wordify.jar
When started, the console will prompt you to enter an integer:
-------------------------------------------
Welcome to Wordify version 1.0 (Java 9.0.1)
-------------------------------------------
Quit by entering 'q' or 'quit'. See this message again with 'h' or 'help'.
Enter 'max' to see the largest number supported, or 'min' to see the smallest.
Please enter an integer to wordify:
Enter an integer, even negative, and it will be converted into English words:
123456789
One hundred twenty three million four hundred fifty six thousand seven hundred and eighty nine
-8274
Negative eight thousand two hundred and seventy four
Valid characters are 0-9
and -
only. Note -0
is invalid because 0
is by definition a non-negative number.
The maximum integer supported is 10^1003-1
, and the minimum is -10^1003-1
. In other words, Wordify supports up to 1 millillion - 1, or one thousand and three nines.
Enter 'h' or 'help' at any time to see the help message.
To see what 10^1003-1
looks like, enter max
. To see what -10^1003-1
looks like, enter min
.
Enter 'q' or 'quit' (or 'x' or 'exit') to end the REPL session
If the integer entered is invalid, a hint about why will be presented. For example:
-0.234
Integers start with a 1 through 9. Please enter an integer to wordify (q to quit):
Here are the given requirements for the Wordify program.
- Only the very first letter is ever capitalized.
- Hyphens and commas are unnecessary.
- There is only one "and" and it comes before the last grouping of numbers below 100. e.g. 100 and 47, but not 1000 nor 100.
- Support negative numbers: -1000 becomes "Negative one thousand".
- REPL support is encouraged
- Include a standalone jar (see
lib/
folder) - Include unit tests (see
src/test/
) - At a minimum, handle anything that would fit inside a 32-bit signed integer.
- Handle any error conditions gracefully.
- The inputs are strictly integers, no fractional values.
- Echo to
System.out
Looking for help? Contact the author at [email protected].
This is a project designed to highlight my development process and how I comment and commit. I didn't squash any commits so the evaluator can see my code evolution. This is the same question Sonatype has been using for years I'm told, so hopefully this can give hints to future candidates. Sonatype is aware of my solution, so please vary your answer.