### Thread: Convert 234 to two three four, 321 to three two one...etc

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
28
Rep Power
0

#### Convert 234 to two three four, 321 to three two one...etc

Hi I'm in a relatively beginner programming class and need to do a program that will convert any 3 digit number to the written wording of each number. For example, 123 to one two three, or 456 to four five six, or 432 to four three two....etc. We aren't into arrays yet, so is there a way to do this without making a string or char array?

Thanks,

Chris
2. #### converting digits to numbers

Well, in that case, you will have to check for each character using the charAt() method of a string instance. You need to use a switch...case statement to check if the digit is 0 ....up to 9, then print out the word as appropriate.
3. If you can't use Strings to get at the digits in the number, another way is to use the % and / operators to extract the digits one at a time. For example 123 % 10 is 3