This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
2. Write a Java program that will reverse any input integer number. For example, if the user enters 1439, your program must find 9341, or if -628 entered, -826 must be cretaed (the output must also be an integer).
I'm sorry Burak, but we try not supply direct answers to assignment/interview questions or provide ready made code samples (please, have a read of this).
We will however help you work through the coding problems you are having. So, what have you tried? Can you post the code you've got so far? Or if you've got nothing, can you explain what is confusing you?
So.. does that code compile? does it run? does it die? does it give you the wrong output? What were you expecting, what did it give you?
folks here will BEND OVER BACKWARDS to help you - but you have to make it easy for them. Everyone volunteers their time, and the harder it is for them to help you, the less likely they are to help.
Just a friendly tip!
also, you should learn to use the code tags. click that 'code' button above where you enter your post, and you'll see them. then paste your source code between them to preserve your spacing. It makes the code about 1000% easier to read.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Jun 24, 2009
Please help me i have to do this now if i can't do this i will fail in exam
Burak Tass wrote:Please help me i have to do this now if i can't do this i will fail in exam
Well, first, you can get rid of all the prime() stuff -- that for a different homework problem.
As for reverse(), it looks like you have written one that will reverse a string. Now, you just need to convert number to string and back -- and take care of negative numbers too. Pretty straightforward, give it a shot...
Burak Tass wrote:ok I see you don't help me and i will fail if you don't send me codes
I am a professional coder. I write Java, Perl, C/C++ and other languages for a living.
I would be happy to provide the answer to ALL three of your problems at my standard rate of $300 / hour, with a four hour minimum. Once you have deposited the money into my paypal account, I will start writing your code for you, and provide it to you as soon as possible.
I will start by apologizing to the orignal poster if I am incorrect in my next set of statements.
Judging by your other threads, and the fact you are asking us to write code for you, I highly doubt the code you posted was written by you. Not only is it pretty lengthy code (albeit not that complex) but huge chunks of it do not relate to the problem you are asking us about.
With that said, Henry has pretty much told you EXACTLY what you have to do. I would suggest a quick google search for "java convert int to string" and "java convert string to int" will probably tell you how to do what you require.
This sounds like it might be an exercise in recursive programming . The idea of displaying the characters of a string in reverse order, without actually reading the string in reverse order, or without storing the characters in reverse order, is a problem that lends itself to recursive solution.