1. Please don't hijack someone else's post. We have plenty of room around here, so just create your own thread. I have split your two posts into a new thread.
2. Take a look at our HowToAskQuestionsOnJavaRanch FAQ. There are a LOT of tips on there on how to make posts here that give you the best chance of being answered.
3. I am about to send you a private message. Please check there in a minute or two.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Also, please remember to UseCodeTags (<-click) next time you post code. I changed your post to include them this time.
As for your problem: The issue is one of logic. You have identified some special cases, when the length of the input is > 1 and the tens digit is equal to 1. But you do not prevent normal output from happening in those special cases. Your option is to do a nested series of ifs like this (pseudocode):
This is pseudocode, and it doesn't handle the 100s digit, but you can add that yourself.
Another option, which would require less change in your code, is when you reach the special case code don't add to the already present output string, instead, simply replace it.
There are a number of other optimizations that can be made, but since this is a beginners programming exercise I won't go into them.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com