Hello every one, i wrote this program that display the reverse of a number through a method called reverse and return void.
i made a string variable to hold the reversed number .
well, i want to improve this so that the method return an integer value of the reversed number.
how can i make the integer variable hold the reversed number and that can be returned to the function such as string variable i made???
i hope you help me......
I Hear I Forget, I See I Remember, I Do I Understand.
You'll need to change just two lines:
The first you'll change into a declaration and initialization of an int. The initial value should be obvious.
The second line takes the current value and adds remainder to the right of it. Is there a mathematical operation or group of operations that can do this? Hint: how do you take 12 and 3 and turn it into 123?
in order to move the result 1 spot for the next digit you need to multiply it by 10 (basicaly appending a 0)
add the next digit
chop off last digit of the input
On a sidenote you might want to make the method do what it says, only return the reverse and not display it, that way the code is reusable and not linked to a messagedialog
you could still call that messagedialog from within your main method in this case.
First, I'd like to thank Stefaan Dutry for his effort to help me but I'd prefer to give me the algorithm not the straight solution
because you really solve my problem and i didn't do any thing except copying the code and running it .
second,i agree with Campbell Ritchie for his words
finally, I'd like to thank you all for helping me...........