• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

logic for a program?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 28394
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would really be interesting if he wanted it solved in french!
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gerardo Tasistro:
It would really be interesting if he wanted it solved in french!


Check here.
reply
    Bookmark Topic Watch Topic
  • New Topic