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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started