February 7th, 2013, 06:50 PM
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?
February 8th, 2013, 05:23 AM
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.
When the programming world turns decent, the real world will turn upside down.
February 8th, 2013, 06:15 AM
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