Question: Please implement a java program below with these 3 different function of recusive method. Thanks Write a recursive method that returns true if the String

Please implement a java program below with these 3 different function of recusive method. Thanks

Write a recursive method that returns true if the String contains the char, otherwise returns false.

public boolean recursiveContains(char c, String s){

// Implement body

}

Write a recursive method that returns true if all the characters in the String are identical, otherwise false. If the String is empty, all the characters are identical.

public boolean recursiveAllCharactersSame(String s){

// Implement body

}

Write a recursive method that returns the number of characters in the String, which may be 0.

public int recursiveCount(char c, String s){

// Implement body

--------------------------------------------------------------------------------------

public class Recursive{

public static double powerN(double x, int n){ if(n==0) { return 1; } else if(n==1) { return x; } else return x*powerN(x,n-1);

}

public static double harmonicSum(int n){ if(n==0) { return 0; } else { return ((double)1/n)+harmonicSum(n-1); } }

public static void reverseDisplay(int value){ if (value <= 0) return;

System.out.print(value % 10); reverseDisplay(value / 10); }

public static void reverseDisplay(String value){ if (value.length() == 0) return; System.out.print(value.substring(value.length() - 1)); reverseDisplay(value.substring(0, value.length()-1)); }

public static void main(String[] args) { double m; m = powerN(15,3); System.out.println(m); System.out.println(harmonicSum(1992)); reverseDisplay(123456789); System.out.println(); reverseDisplay("Norin Chea"); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!