• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Writing numbers

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, everybody. I have the following problem: I need to convert a number into text, e.g., if I get '1' I want to convert it to 'One'. Anyone knows if there is a java program that does it? Any help is deeply appreciated.
Thanks,
Francisco
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt it...you'll just need a table to pull from to map the numerical numbers with the word versions.
For instance, if the number is between 100 and 1000, you know you'll need to get the first digit (e.g. output "one" for 1, "six" for 6, etc), then "hundred", then do the same with the tens and ones digits.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is something that I started for you, if you add to it I would appreciate any additional work. I am sure that there are better ways to do this but this is quick:

[ November 21, 2003: Message edited by: Sam Moran ]
[ November 21, 2003: Message edited by: Sam Moran ]
 
Sam Moran
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I spent a little more time and did some cleaning and pruning. I have declared the 2 arrays as global and assign the values in the Main. Now I have two simple functions that work up to 99,999:

[ November 24, 2003: Message edited by: Sam Moran ]
reply
    Bookmark Topic Watch Topic
  • New Topic