Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write recursive methods for each of thefollowing tasks. You can place all of you

ID: 3615254 • Letter: W

Question

    Write recursive methods for each of thefollowing tasks. You can place all of your methods into a singleJava class. Although these problems are solvable without recursion,use recursion in your solutions for this assignment. The recursivesolutions for these are quite short.

public static double power(double b, inte) This should return the resultwhen b is raised to thee power. Your method should work for any values(positive, negative, or zero) of b ande.

public static String reverse(Strings) This should return a stringcontaining the characters of the string sin reverseorder. Hint: use the substring()and/or charAt()methods ofthe String class to isolate individualcharacters.

public static booleanisPalindrome(String s) This shouldreturn true or falsedependingon whether the string s is apalindrome (i.e., a string that is identical to itsreverse). Do not call your reversemethod! Hint: use thesubstring() and/orcharAt() methods of theString class to isolate individualcharacters.

public static int gcd(int x, inty) This should return the greatest commondivisor (GCD) of the numbers xand y. You can assume thatboth x 0 and y 0. The GCDof two numbers is the largest number that evenly divides bothnumbers. For example, GCD(9,27) = 9 and GCD(21,49) = 7. The GCD canbe computed using the Euclidean algorithm, which says GCD(x,y) = xif y is 0, and GCD(x,y) = GCD(y,remainder of x /y)otherwise.

Explanation / Answer

please rate - thanks import java.util.*; public class recursivefunctions {public static void main(String [] args) {Scanner in=new Scanner(System.in); int num1,num2; boolean palin; String text; System.out.println("Enter a string to reverse: "); text=in.nextLine(); System.out.println(text+" -reversed is: "+writeBackward(text));   System.out.println("Enter a string to check if it's a palindrone:"); text=in.nextLine(); palin=isPalindrome(text); if(palin)    System.out.println(text+" is a Palindrome"); else     System.out.println(text+" is not aPalindrome");    System.out.print("enter a number whose power you want to find:"); num1=in.nextInt(); System.out.print("Enter the exponent: "); num2=in.nextInt(); System.out.println(num1+"^"+num2+" = "+power(num1,num2)); System.out.print("enter a number : "); num1=in.nextInt(); System.out.print("Enter another number: "); num2=in.nextInt(); System.out.println("The GCD of "+ num1+" and "+num2+" ="+gcd(num1,num2));    } public static boolean isPalindrome (String str) {   boolean result = false;       if (str.length()
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote