Question: Write a java program (name it countOccurrences) as follows: The main method prompts the user to enter a string and a character. The method then
Write a java program (name it countOccurrences) as follows:
The main method prompts the user to enter a string and a character. The method then calls Method Count()(defined blew) to count and return the number of time (occurrences of) the entered character appeared in the entered string. The main method then prints the occurrences with proper label as shown below.
Method Count()is of type integer and takes a string and a character parameters. The method recursively counts and returns number of time the character appeared in the string. Document your code and use proper prompts for inputs and format outputs as shown below.
Entered string: This is a test
Entered character: i
Occurrences of letter i in the string is 2 times.
Entered string: Hello World!
Entered character: l
Occurrences of letter l in the string is 3 times.
Entered string: Welcome to Java
Entered character: w
Occurrences of letter w in the string is 0 time.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
