public class Test8{ //replace this with your solution public static int numWords(String s) { return 1; } public static void main(String args[]){ String[] strings = { "how many words here?", "to be or not to be, that is the question", " how about merry-go-round ", " !&$%--$$!!*() foo_bar_baz ", "x", " ", " ", "" }; int[] answers = { 4, 10, 3, 2, 1, 0, 0, 0 }; int correct = 0; int wrong = 0; for(int i = 0; i < answers.length; i++){ try{ if(numWords(strings[i]) == answers[i]){ correct++; } else { wrong++; System.out.println("Error on \""+strings[i]+"\""); System.out.println("\tshould be "+answers[i] + " but was " + numWords(strings[i])); } }catch(Exception e){ System.out.println(e); wrong++; } } System.out.println("********"); if(wrong > 0){ System.out.println("FAIL"); }else{ System.out.println("PASS"); } } }