Remove catch from outside while and put the following statements in try block and write catch block for it.
answer = dataIn.readLine();
x=Integer.parseInt(answer);
I have done this for you as foll. Its working fine.
I have not read your logic completely but I guess
you should use array to store the numbers_in_words and find out the index to search and get the the number in words. This logic will work fine for you.