Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using recursion to display the users input

Status
Not open for further replies.

wavo7

Technical User
Jul 18, 2001
11
US
Hello all,
Let's say that the user puts in ANY number he wants to. How would you be able to show that number to him in WRITTEN FORM. Like this:
You enter: 5690
The output would say: Five thousand six hundred ninety

I can get the user's input, and hold onto it, but figuring out how to write it out is another story. Any helpful hints or suggestions would be appreciated.

~Wavo
 
ur case is possible

get the number as a string and find out its length

do some sort of a manipulation like this

ex number = 1234

length=4

first step
1234/1000 and get the remainder 1,234
then do 1234 - 1*1000 which will give u 234
then do 234/100 , 2,34
234 - 2*100 = 34
then do 34/10 = 3,4
34 - 3*10 = 4

each time use a case statement to print out the exact name for the number

hope this helps
sriram
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top