Question: 4- implement count method in Q4 class. It is a recursive method that * finds the number of occurrences of a specified letter in a

4- implement count method in Q4 class. It is a recursive method that * finds the number of occurrences of a specified letter in a string. * For example, count("Welcome",'e') returns 2. * NOTE: Note that writing a non-recursive method will lead to 0 point.

System.out.println("Q4 = [15 marks] ================================="); System.out.println(Q4.count("Welcome",'e'));

5- implement stats method in Q4 class to perform statistics for the * occurrence of each character in the provided sentence string. * Save the results into a hashmap, with key = character and value = occurrence * For example, "no news is good news" should return a hashmap with value of * { =4, s=3, d=1, e=2, w=2, g=1, i=1, n=3, o=3} * NOTE: the first key indicates space.

String sentence = "no news is good news"; System.out.println("Q5 = [15 marks] ================================="); System.out.println(Q5.stats(sentence));

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!