View Question
 ```Description In this problem, write several recursive methods as a part of a class called Recursion. Write appropriate code to test them as a part of the "main" method. The methods as described below are not necessarily related, but should be made part of the same class for convenience. Write a method called NumberofDigits that returns the number of digits in an integer. Write a method called SumRange that takes two arguments n and m and returns the sum of all integers from n to m, both inclusive. Write a method called Palindrome that checks if a given string is a palindrome. It should return a Boolean value. A string is a palindrome if it reads the same forwards and backwards (e.g. "abba"). Write a method called Countdown that takes a number n as it argument and prints out the numbers in a decreasing order (one per line) starting with n all the way down to 0. Write a procedure called Howmany that takes two arguments: an array (of integers) and an element (integer) and returns the number of times the elements occurs in the array. Procedure Write a class called "Recursion" with the five methods as describe above. Write a main method and write the necessary code to test the correctness of each method. Make sure that at least one of the recursive methods is tail-recursive.```
 ```Hi math01-ga, Welcome back! :-) As usual, I have provided the required Java code below. To compile and run this code, you will need the Java2 SDK. You can download the Java SDK from : - Download : Java(TM) 2 SDK, Standard Edition, v 1_4_0_03 ( http://java.sun.com/j2se/1.4/download.html ) A free Java IDE (if you need one) can be found at : - The RealJ Java IDE ( http://www.realj.com ) The code provided below has been tested with RealJ and JDK 1.4. +-----------------------------------------+ Copy the given code into a file called 'Test.java'. The code contains the following classes: + class Test | |_____main(String args) :This method tests the recursion methods. | + class Recursion |----NumberOfDigits(int) |----SumRange(int,int) |----Palindrome(String) |----Countdown(int) |----Howmany(int[],int) +-----------------------------------------+ The recursion methods are pretty simple and pretty much self explanatory. If you have problem following the flow of the program, just ask me for a clarification and I will help you out. As for the requirement of atleast one tail recursive function, the function Countdown() meets your needs. For a definition of the term "tail recursion", check out: - NIST: tail recursion ( http://www.nist.gov/dads/HTML/tailrecursn.html ) So, without further delay, here is the code: +-----------------------------------------+ import java.io.*; // Test Class: Contains the main method which tests // the methods of the Recursion class. public class Test { public static void main(String args[]) throws IOException { // Setup out keyboard reader BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); // Create Recursion class object Recursion R = new Recursion(); int choice = 1; while( choice!=0 ) { do { System.out.print( "\n\n\tRecursion Test Menu" + "\n 1. Test Function NumberOfDigits()" + "\n 2. Test Function SumRange()" + "\n 3. Test Function Palindrome()" + "\n 4. Test Function Countdown()" + "\n 5. Test Function Howmany()" + "\n 0. Exit" + "\n\nEnter Your Choice(0-5): "); choice = Integer.parseInt( buf.readLine() ); }while( choice<0 || choice>5 ); switch(choice) { case 1: System.out.println(" Testing Function NumberOfDigits() :"); System.out.print(" Enter a number: "); int num = Integer.parseInt( buf.readLine() ); System.out.println(" The number " + num + " has " + R.NumberOfDigits(num) + " digits."); break; case 2: System.out.println(" Testing Function SumRange() :"); System.out.print(" Enter a number n: "); int n = Integer.parseInt( buf.readLine() ); System.out.print(" Enter a number m: "); int m = Integer.parseInt( buf.readLine() ); System.out.println(" The sum of numbers from "+n +" to "+m+" is "+R.SumRange(n,m)); break; case 3: System.out.println(" Testing Function Palindrome() :"); System.out.print(" Enter a string : "); String str = buf.readLine(); System.out.println(" The function returned " + R.Palindrome(str) + "."); break; case 4: System.out.println(" Testing Function Countdown() :"); System.out.print(" Enter a number: "); int count = Integer.parseInt( buf.readLine() ); System.out.println(" The output of this function is: "); R.Countdown(count); break; case 5: System.out.println(" Testing Function Howmany() :"); System.out.print(" Enter the number of array elements: "); int arrLen = Integer.parseInt( buf.readLine() ); if( arrLen==0) break; // Create array and populate it int[] array = new int[arrLen]; for(int i=0; i