GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes How to convert numbers to words in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to convert numbers to words in java?" Watch "How to convert numbers to words in java?" New topic
Author

How to convert numbers to words in java?

Veronica Martinez
Greenhorn

Joined: Dec 02, 2011
Posts: 1
Example:
2 000 000
Output:
Two Million

The range of numbers to be converted is up to 2 million.
Thank you so much. )
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

We typically won't write programs for you because we are NotACodeMill. Instead, we answer questions you might have about getting it done yourself. So please ShowSomeEffort: What code do you currently have and where are you getting stuck?


Steve
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

i'm glad i don't have to write a program to do that


SCJP
Visit my download page
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

If this isn't a homework question, then the best way to do it is to search the Internet for code which already does it. I'm sure such code exists. So, is it a homework question? (It's perfectly okay to discuss homework questions here, but like Steve said, don't expect to be given the answer.)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11351
    
  16

This is also very similar to one of our CattleDrive problems. You may be able to search our forums and find some hints already here.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7892
    
  21

Veronica Martinez wrote:The range of numbers to be converted is up to 2 million.

It's actually quite a fun problem to solve; though how useful it is, I'm not sure.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Winston Gutkowski wrote:It's actually quite a fun problem to solve; though how useful it is, I'm not sure.

Winston


Some of us still live in a world where payments are made with pieces of processed dead tree material called, variously, "cheques" or "checks". Many of them are produced by computers these days, but they still have to have the payment amounts printed on them in words as well as numbers.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7892
    
  21

Paul Clapham wrote:Some of us still live in a world where payments are made with pieces of processed dead tree material called, variously, "cheques" or "checks". Many of them are produced by computers these days, but they still have to have the payment amounts printed on them in words as well as numbers.

Which seems almost absurdly redundant in this day and age, since the whole reason for writing out the amount in the first place was to make sure that the puny human writing the cheque didn't make a mistake. But I take your point.

Winston
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39053
    
  23
But a human has to read the cheque and copy the numbers onto a screen.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7892
    
  21

Campbell Ritchie wrote:But a human has to read the cheque and copy the numbers onto a screen.

Not since MICR (first tested in 1959) they don't.

Winston
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11351
    
  16

Deadly Byte,
Your post was moved to a new topic.
Frances Hollis
Greenhorn

Joined: Sep 02, 2006
Posts: 17
Winston Gutkowski wrote:
Campbell Ritchie wrote:But a human has to read the cheque and copy the numbers onto a screen.

Not since MICR (first tested in 1959) they don't.

Actually, the preprinted MICR is only the bank and account information. The amount still must be read by a human (or OCR, which is hit or miss).

Ann
Anna Harris
Greenhorn

Joined: Aug 21, 2012
Posts: 13
I can't provide you the whole program for that conversion. Try to write a conversion program for that if any problem arises then we will help you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to convert numbers to words in java?