• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting Number to Word

 
Ankita Jha
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

In my application i a need which will convert number to Word.
Problem is ,When i have whole number like (10000 or 2260) etc,it works properly.
Byt i have some number like 158.32 then it shld be read as "One hunderd fifty eight and thirty two paise" but it read the number as "Fifteen thousand eight hundred and thirty two"

Im pasting my code below.Any help wil be appreciated.Thanks in advance.
>
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One problem in your code what I could notice is in


I have not went through your entire code but probably calling the convertNumber function twice might solve your requirement


 
Ankita Jha
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Swastik Dey
Got it working
 
salvin francis
Bartender
Posts: 1200
9
Eclipse IDE Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
program can be made much more simpler:

eg:


so units[4] would return "Four", I dont see why you require so many switch cases etc.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic