Question: a java program Write a program that prompts for and reads in a non-negative int constant into an int variable. Your main method should call
a java program
Write a program that prompts for and reads in a non-negative int constant into an int variable. Your main method should call a recursive method reverseInt, passing it the int value read in. reverseInt should return to main the int value obtained by reversing the digits of the number it is passed. For example, if reverseInt is passed 123, it should return (not display) the value 321. main should then display the value returned. Test your program with 0, 1, 12, and 123. Hint: divide by 10 to strip off the rightmost digit. To isolate the rightmost digit, divide by 10 and take the remainder (use the % operator). reverseInt should not convert the int value it is passed to a string.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
