Marian https://gptc.blackboard.c ×/Dwww.ebooksbucket.com/. × Dwww.ebooksbucket.c
ID: 3662703 • Letter: M
Question
Marian https://gptc.blackboard.c ×/Dwww.ebooksbucket.com/. × Dwww.ebooksbucket.com/uploads/itprogramming/java/Introduction-to Java%20Programming Comprehensive Version·pdf *I8.7 (Fibonacci series) Modify Listing 18.2, ComputeFibonacci.java, so that the pro- gram finds the number of times the fib method is called. (Hint: Use a static variable and increment it every time the method is called.) Section 18.4 * 18.8 (Print the digits in an integer reversely) Write a recursive method that displays an int 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 and displays its reversal * I8.9 (Print the characters in a string reversely) Write a recursive method that dis- plavs a string reversely on the console using the following header: public static void reverseDisplay(String value) 3:03 PM Search the web and Windows O e 1/21/2016Explanation / Answer
import java.util.Scanner;
/**
*
*/
/**
* @author Srinivas Palli
*
*/
public class ReverseIntRecursion {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
System.out.print("Enter an Integer:");
int value = scanner.nextInt();
reversDisplay(value);
}
/**
* method to print reversed value recursively
*
* @param value
*/
public static void reversDisplay(int value) {
System.out.print(value % 10);
if (value > 10) {
reversDisplay(value / 10);
}
}
}
OUTPUT:
Enter an Integer:12345
54321