I need to help. I am working on a billing project using jsp&mysql, Where the total amount should be calculated and displayed Numeric as well as Text. For ex:

Another place to take a peek is the "cattle drive" forum. I believe one of the projects that students do involves just this, describing numbers with text. I'm sure that, if your read through the threads in that forum, you will get some good hints.

An excellent problem! For fun (I mean it, fun!) see if you can make a program that works for 0 through 9. Then for 10 through 19. Then for 20 through 99. Then for 100 through 999. You can actually do it without erasing too much code from one run to make the next one work.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi

// // so quintillions is as big as it gets. The // program would automatically handle larger // numbers if this array were extended. // private static final String[] groups = { "", " thousand", " million", " billion", " trillion", " quadrillion", " quintillion" };

private String string = new String();

public String getString() { return string; }

public String EnglishNumber(long enteredNo) {

// Go through the number one group at a time. //System.out.println("groups.length= " + groups.length); for (int i = groups.length - 1; i >= 0; i--) {

// Is the number as big as this group?

long cutoff = (long) Math.pow((double) 10, (double) (i * 3));

if (enteredNo >= cutoff) { int thisPart = (int) (enteredNo / cutoff);

// Use the ones[] array for both the // hundreds and the ones digit. Note // that tens[] starts at "twenty".

enteredNo = enteredNo % cutoff;//to check for big numbers which are greater than or equal to 1 million //System.out.println("enteredNo is : " + enteredNo); } }

Demo ntw = new Demo(); String Englishword = null; Englishword = ntw.EnglishNumber(1000000); System.out.println("The entered number in words is : " + Englishword);

Okay, now internationalize your appliction I was just thinking about this recently because I was helping my seven year-old with her French homework and she's learning her numbers: 92 = "quatre-vingt-douze" (four twenties and twelve).

Hi Ashwin, good effort. but i think it will not work properly more or equal to 6 digit. i know we can do this by adding more into String array. but the question is there can be general way to convert any number of any length.

There's an important mistake in the big long example solution. It uses Math.pow(). The problem being solved is entirely an integer arithmetic problem and no floating-point operations are necessary. They could give accuracy/rounding problems and are also unnecessarily slow.

To do powers of ten in integer arithmetic, a usually-good-enough solution isuse a simple "for" loop. If you need to optimise performance (and you very rarely actually do need to do so), store pre-calculated values in an array.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.

Hi though i am replying to a very old thread, but hope this will be helpful. The code does not use any floating point calculation and Math.pow function.