Write a complete program that has a method called wordCount that accepts a Strin
ID: 3645400 • Letter: W
Question
Write a complete program that has a method called wordCount that acceptsa String as its parameter and returns the number of words in the String. A word is a sequence of
one or more non-space characters (any character other than ' '). For example, the
call wordCount("hello") should return 1, the call wordCount("how are you?") should return 3, the
call wordCount(" this string has wide spaces ") should return 5, and the call wordCount("
") should return 0.
Your program must keep asking the user if there are any more sentences to be processed.
Meaning that your program must ask the user if he/she wants to counitue.
Your method can only have one return statement.
In your main method you must call the wordCount(
Explanation / Answer
public static int wordCount(String s){int counter=0; for(int i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.