Does anybody made a program that will translate a number to it's word equivalent?
I can't make an algorithm for it.SAMPLE:
number: 12345
word: twelve thousand three hundred fourty five
Does anybody made a program that will translate a number to it's word equivalent?
I can't make an algorithm for it.SAMPLE:
number: 12345
word: twelve thousand three hundred fourty five
It appears this question has been discussed before
You can use the board search to find some examples. Here's a couple
http://cboard.cprogramming.com/showthread.php?t=44180
http://cboard.cprogramming.com/showthread.php?t=37938
I'd read the threads for help with an idea, then try to implement your own solution.
I wrote my own . . . fancy, but it used a long, so it couldn't do 10,000,000,000.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I have a program in Emacs Lisp that does this task. If you can figure out the language (It helps to use the Emacs text editor), you'll see how the algorithm works. Mind, it would return "twelve thousand three hundred forty-five" for 12345, because that's the correct form. And I sort of didn't comment the code at all, either, but it's relatively short. The function 'wordate' is the one that converts the number to text; the rest are helper functions. So the expression (wordate "12345") would return "twelve thousand three hundred forty-five". Hopefully this helps you write the program in your language of choice.