In: Computer Science
Write a recursive method that displays an integer value reversely on the console using the following header:
public static void reverseDisplay(int value)
For example, reverseDisplay(12345) displays 54321. Write a test program that prompts the user to enter an integer, invokes the method above, and displays its reversal.
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! =========================================================================== import java.util.Scanner; public class ReverseNumber { public static void reverseDisplay(int value) { if (value == 0) return; System.out.print(value % 10); reverseDisplay(value / 10); } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter an integer number: "); int value = scanner.nextInt(); reverseDisplay(value); } }
====================================================================