Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

logic for a program?  RSS feed

 
priyanshu bhardwaj
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
plz give me the logic to write a program so that if we give anything in Number
the result is given as text
for example
1200 is printed as twelve hundred
Thanks
 
Curtis Brown
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This smells like a homework question. In fact, if you'd searched, you'd have discovered a person (a possible class-mate?) posted the question only about a week ago.

Nevertheless, try to think about what *you* do to convert numerals to words, and see how you might then teach a computer to do same.
 
Dave Tuttle
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a tough one (homework problem or not).
I don't think there's a simple way to do it. You'll have to go case-by-case. For example, 0-9 will be print "zero", "one", etcetera. 10-19 will be another case, 20-29, etcetera. As you add more cases you'll probably see ways to factor out general functions.
--Dave
 
Paul Clapham
Sheriff
Posts: 22502
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find the whole thing here:

http://icu.sourceforge.net/icu4j_faq.html

in the "RuleBasedNumberFormat" class. Of course if it's actually homework, you wouldn't be able to submit that as your answer, but if it's an actual requirement then (licence permitting) you could use it.
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would really be interesting if he wanted it solved in french!
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gerardo Tasistro:
It would really be interesting if he wanted it solved in french!

Check here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!