i'm wondering how would you translate a number from 0-9999 that the user enters into an english statement for ex: 123 is one hundred twenty three. 5041 is five thousand forty one. This isn't homework just a problem in my book that i can't figure out, i can post the whole problem if anyone is interested. Can you test each individual digit (say test how many digits are in the number and what position its in?)
You can separate digits using operators / and %. x%10 is the last digit of x and x/10 is everything but the last. If you do that in a loop, you can put all of your digits into an array.
Another a bit cheap way is to read the number as a string. That way the separation is already done for you (or rather, the composition is not done).
Basically, the algorithm is to seperate each of the digits and to inspect them. for example,
123 can be seperated as 1*10^2+2*10^1+3*1
using these digits and their respective positions, you can obtain the equivalent expression. But you have to pay special attention to "Teens". I have the program. If you want to give it a try, you can do it yourself. But if you want to have a look at it anyway, you can reply in this post.
yeah im still pretty confused, would i have to make a parallel array that has the english word for the number #: zero, one, two, three, .... twenty. then another array for twenty,thirty, forty, fifty, .... one hundred then the hundreds and then the thousands.
idk if you have the code written i definitely wouldn't mind taking a look