Question: If the word is contained in the text, return the number of times it is contained. Otherwise return 0. If there is no word, or

 If the word is contained in the text, return the number

If the word is contained in the text, return the number of times it is contained. Otherwise return 0. If there is no word, or no text, return -1. Look at whole words, "the" is not contained in "these". Capitalization is not cosidered. hasword("the", "The weather outside is frightful.") returns 1 hasword("any-where", "I can find any-string any-where.") returns 1 hasword("farm", "Old McDonald had a farm. EI EI O. And on that farm he had a cow.") returns 2 hasword("do", "I love dogs, do you?") returns 1 hasword("Army", "I have decided to join the Navy.") returns o hasword("", "This is the fist line of over 1000 lines.") returns -1 @param word String, @param text String, @return returns the count of word in text, or -1 if either is null public static int countWord (String word, String text) //your code here: return -1; }//end countWord

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!