aspose file tools*
The moose likes Beginning Java and the fly likes coding problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

coding problem

MOHAMMAD SALEEM
Greenhorn

Joined: Nov 24, 2001
Posts: 4
double d = 546954.14;
could anyone please tell me how do I pick up the individual values
The output format is :
5 hundred 46 thousand 9 hundred 54 dollars 14 cents
A full code would be appreciated.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
hmmmm . . . homework.
Perhaps you could convert it to a String using the toString() method of Double. Then you could identify the value of each byte by using the charAt(index) method of String.
You can find the number of chars in the whole thing by taking the String above and using the length() method. For instance your number will be 9 chars long. The last three will always be the decimal and the cents. So the "dollars" will always be at (length - 4) and (length - 5). The hundreds will always be at (length -6) the thousands and (length -8) and (length - 7) and the hundred thousands at (length - 10) and (length - 9). etc.
Is that enough of a start?

"JavaRanch, where the deer and the Certified play" - David O'Meara
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
MOHAMMAD
You already asked this question and received two replys here: http://www.javaranch.com/ubb/Forum33/HTML/004133.html.
Please dont repost the same question multiple times, if you didn't receive a satisfactory answer post a reply to the current thread clarifying your question or telling why it was satisfactory. If you create new threads all the time the people that did respond will think they are being ignored.

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform


Dave
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

You have already posted this question. And two people have given you clues. Most likely that is about as much help as you are going to get until you post some code. http://www.javaranch.com/ubb/Forum33/HTML/004133.html


Please ignore post, I have no idea what I am talking about.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: coding problem