Define a method named getWordFrequency that takes an array of strings, the size of the array, and a search word as parameters. Method getWordFrequency() then returns the number of occurrences of the search word in the array parameter (case insensitive). Then, write a main program that reads a list of words into an array, calls method getWordFrequency() repeatedly, and outputs the words in the arrays with their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain less than 20 words. Ex: If the input is: 5 hey Hi Mark hi mark the output is: hey 1 Hi 2 Mark 2 hi 2 mark 2 Hint: Use the equalsIgnoreCase() method for comparing strings, ignoring case. The program must define and call a method: public static int getWordFrequency(String[] wordsList, int listSize, String currWord)
Define a method named getWordFrequency that takes an array of strings, the size of the array, and a search word as parameters. Method getWordFrequency() then returns the number of occurrences of the search word in the array parameter (case insensitive).
Then, write a main
Ex: If the input is:
5 hey Hi Mark hi mark
the output is:
hey 1 Hi 2 Mark 2 hi 2 mark 2
Hint: Use the equalsIgnoreCase() method for comparing strings, ignoring case.
The program must define and call a method:
public static int getWordFrequency(String[] wordsList, int listSize, String currWord)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images