Write a recursive method that displays the digits of an inte

Write a recursive method that displays the digits of an integer in reverse using the following header: public static void reverseDisplay (int value) For example, reverseDisplay(12345) should display 54321. Write a main method that prompts the user to enter an integer and displays it in reverse by calling the reverseDisplay method.

Solution

2)-Reverse a number using recursion public static void main(String[] args) { reverseDisplay(12345); } /* Recursive function to reverse digits of num */ public static void reverseDisplay(int number) { if (number < 10) { System.out.println(number); return; } else { System.out.println(number % 10); reverseDisplay(number/10); } }
 Write a recursive method that displays the digits of an integer in reverse using the following header: public static void reverseDisplay (int value) For exampl

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site