It's not a secret anymore!
The moose likes Java in General and the fly likes Converting Number to Word Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Converting Number to Word" Watch "Converting Number to Word" New topic

Converting Number to Word

Ankita Jha
Ranch Hand

Joined: Sep 15, 2008
Posts: 55
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

Joined: Jan 08, 2009
Posts: 1584

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

Joined: Sep 15, 2008
Posts: 55
Thanks Swastik Dey
Got it working
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 1138

program can be made much more simpler:


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

I agree. Here's the better link:

I agree. Here's the link:
subject: Converting Number to Word
It's not a secret anymore!