Solved

converting digits into numbers

Posted on 2001-09-06
3
413 Views
Last Modified: 2012-05-04
Let us say i deposited money of 1000 Dollards then i the deposited amount should be
printed out like 'one thousand dollars'. if deposit  29932 million it should print
twentynine thousand nine hundreden thirty two.is there any way i can achieve this
thru java programming???
0
Comment
Question by:gauty
3 Comments
 
LVL 7

Accepted Solution

by:
tomboshell earned 30 total points
ID: 6460278
Yes.  If it is an int then use a switch case structure. If it is a string then change it to an int. Better yet if it is a string recursively break it down into sub parts, goto another method with each sub-part where the switch is and then store the wording for print-out.  Break it down from right-to-left, the tens and hundreds you have to be careful about, but the others (thousands and millions, ect) you can reuse a case.  
talk through:
29932
first pass = in 2 out two  :count = 1
second pass = in 3 out thirty  :count =2
third pass = in 9 out nine hundred  :count =3
fourth pass= in 9 out nine thousand  :count =4
fifth pass= in 2 out twenty  :count =5

use a counter to 'remember' where you are.  Sorry about not giving code, but this question looks suspiciously like homework.  

Tom
0
 
LVL 20

Expert Comment

by:Venabili
ID: 8908438
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points for tomboshell  

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venabili
EE Cleanup Volunteer
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now