1) turn off your computer.
2) get some pencil and paper
3) work through the steps on how YOU would do it by hand, if you have nothing but the supplies in front of you. Literally write down the steps.
4) revise the steps until a young child could follow them without needing to ask you questions.
when you've done the above, you will know how to write your code.
Another tip - when you do write your code, don't write 24 (or probably more) before you compile and test.
split your process into component parts and write methods for each, instead of globbing all this into a single chunk of code. Converting a digit to words is in no way dependent on how you get the digits. So, at minimum, you should have a method that takes a digit as a parameter and converts it. Then you can call it as often as you want.
Splitting a number into individual digits has nothing to do with printing out those digits, so that should be a separate method.
Test your methods independently.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors