Possible Duplicate:
How can I convert an integer into its verbal representation?
Consider i have a 5 digit number say 45456
and i want to print it as Forty five thousand four hundred and fifty six
using c#. Any suggestion.
Possible Duplicate:
How can I convert an integer into its verbal representation?
Consider i have a 5 digit number say 45456
and i want to print it as Forty five thousand four hundred and fifty six
using c#. Any suggestion.
Try this:
http://letsblogabout.net/post/Converting-Numbers-to-Words.aspx
Also see: this question
I dont feel like writing out the code (plus its your homework, so you can do that part), but here's what you'll need to do:
NB. my points are really, really generic. so I'm looking at numbers that can be more than just 5 digits. if it's JUST five digits you care about, you can solve it with just a basic switch statement that substitutes numbers from a list:
given 45456:
subsitute the first number with with the sub-100 value (so 2 is replaced with 'twenty', 3 with 'thirty', 4 with 'forty', etc)
subsitute the second number with the straight up value (so 2 is 'two', 3 is 'three', etc)
add the word 'thousand'
subsitute the third number with a hundreds value (so 2 is 'two hundred', 3 is 'three hundred')
subsitute the fourth number with the sub-100 value (so 2 is replaced with twenty, etc)
subsitute the fifth number with the straight up value.
note that the first and second steps are identical to the last two.
I hope this helps :)