Recursive

I need to write a recursive method that displays a non negative integer with commas in the correct locations. For example, it should display:  20131 as 20,131.

I need to write a program to test the recursive method. Using Boolean value to distinguish the first recursive copy from the remaining ones.

Show the output for the 3 separate numbers: 43, 648         148, 348, 245          349
arhinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

robthewolfCommented:
Is this academic? If so please try to do it yourself and post questions and code when you get stuck.  No one will give you the answer if this is academic work that you are supposed to do yourself.  If it is not academic please explain why you need to do it recursively.
0
arhinAuthor Commented:
If you can help in another way then please go ahead. You need not handle it recursively. Its my own work. Its not academic
0
robthewolfCommented:
ok, i just thought it was strange that you said that it needed to be recursive.
in that case you need to look at the Java api for the number formatters.
you can specify a format and it will output the number as a string according to that format.  have a look at these:
http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html

and some simple explained examples of how to use them here:
http://www.kodejava.org/examples/102.html
http://www.exampledepot.com/egs/java.text/FormatNum.html

no need to reinvent the wheel, most things like this are handled in the api somewhere, dont be afraid to look for them ;)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
robthewolfCommented:
A number formatter will do exactly what the asker wants to achieve and very simply.  I have given plenty of resources and examples on other sites for the asker to implement what they need.  Given the askers comment that it does not have be recursive I feel that I have answered this question satisfactorily.
0
robthewolfCommented:
I am interested in the outcome, mainly to understand what was wrong with my suggestion, or alternatively to see that the asker understands how my suggestion will solve their problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.