Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

coding problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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?
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
    Bookmark Topic Watch Topic
  • New Topic