|
Re: please help me on this simple program...
|
Posted: Sep 7, 2005 12:02 AM
|
|
Of course you are a student. I wrote programs like this during my school days and never after. It helps understanding String operations.
1. separate the numbers before and after the separator, build Strings displaying those numbers.
3. converting the numbers after the separator is eays. Just check every single char and print it's "name" (one, two, three) out.
4. the part before the separator is a bit more complicated because you need the words "twenty", "thirty" ... Split the String representing the number like this: 0,00,0,00,0,00,0,00 The Strings with just one character are to treat like the digits after the separator. For those with two characters: You need a special threatment for the numbers from 0 to 19, for the others you must build the name of the first digit (twenty, thirty), then the name for the second digit (one, two)
5. "hundred": Just insert it after every SINGLE char of the patten shown above.
6. "thousand", "million". Best thing would be an aray with the names, then check on wich position of the splittedf Strin you are. This word allways comes after the parts with TWO chars.
|
|