Solved

converting digits into numbers

Posted on 2001-09-06
3
416 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing to a specific printer tray (HP 806dn printer) 3 83
how do i compare an object based on two fields 6 48
Java DateChooser? 3 29
Java Loop 6 48
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

930 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

9 Experts available now in Live!

Get 1:1 Help Now