i need help with how to write a method that displays numbers in reverse form in java. thank you
1. Sample input and (expected) output would help in understanding the question.
2. Mention your exact problem. I mean if you have an approach then post it or if you have written the code and its giving an error or the output is not as expected then post the code along with the expected output and actual output.
i need help with how to write a method that displays numbers in reverse form in java. thank you
Hi
Reversing a number can be done in the following steps
1) write a method that takes an int value as parameter
2) convert that int value into String using Integer.toStrin g()
3) Now make this string a StringBuffer and use reverse() of StringBuffer to reverse the number and parse it to Int
1.Find the no of digits in given no using % n /
2.Then find the last digit , multiply it by 10 power n , n-no of digits in given no
3.n:n-1 n find the digit previous to last , multiply by 10 pow n-1,den add it wit previous sum
4.Perform 2 n 3 until n:0
Comment