public class StringLab { public static void main(String[] args) { String s = "It is raining outside, and it looks like it will continue for a WHILE!"; System.out.println("Length is: " + wordCount(s)); System.out.println("Average length is: " + averageWordLength(s)); System.out.println("looks in s: " + wordSearch(s, "looks")); System.out.println("rain in s: " + wordSearch(s, "rain")); System.out.println("While in s: " + wordSearch(s, "While")); } public static int wordCount(String str) { String words[] = str.split(" "); // What does memory look like here? [Diagram1] return words.length; } public static double averageWordLength(String str) { double avg = 0.0; String words[] = str.split("[ \t.!,?:;]"); double total = 0.0; for (int i=0; i < words.length; i++) { total += words[i].length(); } avg = total / wordCount(str); // What does memory look like here? [Diagram2] return avg; } public static boolean wordSearch(String line, String word) { String words[] = line.split("[ \t.!,?:;]"); String wordLower = word.toLowerCase(); for (int i=0; i < words.length; i++) { if (words[i].toLowerCase().equals(wordLower)) { return true; } } return false; } }