Write your code in the file WordCountjava Your code should g
Write your code in the file WordCount.java. Your code should go into a method with the following signature. You may write your own main method to test your code. The graders will ignore your main method: public static int countWordsfString original, int minLength){} Your method should count the number of words in the sentence that meet or exceed minLength (in letters). For example, if the minimum length given is 4, your program should only count words that are at least 4 letters long. Words will be separated by one or more spaces. Non-letter characters (spaces, punctuation, digits, etc.) maybe present, but should not count towards the length of words.
Solution
//WordCount.java public class WordCount { public static int countWords(String original, int minLength) { int counter = 0; for(String str: original.split(\" \")) { System.out.println(str); if(countLetters(str) >= minLength) { counter++; } } return counter; } public static int countLetters(String word) { int letterCounter = 0; for(int i = 0; i < word.length(); i++) { if( Character.isLetter(word.charAt(i)) ) { letterCounter++; } } return letterCounter; } }