Question: Write a method that uses recursion to count the number of times a specific character occurs in an array of characters: for example, char[ ]
Write a method that uses recursion to count the number of times a specific character occurs in an array of characters: for example, char[ ] test = {T, h, i, s, , i, s, , t, h, e, , s, t, r, i, n, g}. The charCount method counts the number of times a character appears in the portion of the array starting at a specified subscript. Remember that in (case sensitive) Java that T is different from t, so make adjustments to your program so they are counted as the same character.
WHEN THE USER ENTERS A CHARACTER IT IGNORES THE CASE. LOWER CASE AND UPPER CASE SHOULD COUNT AS SAME CHARACTER
The method header is: public static int charCount(char[ ] array, int start, char ch).
Demonstrate the method with a driver program called CharacterCounter, that prompts the user to enter a character, and then displays the number of occurrences of the character in the array.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
