@@ -0,0 +1,1300 @@
+package codingbat.string3;%0A%0A/*%0A * Given a string, count the number of words ending in %0A * 'y' or 'z' -- so the 'y' in %22heavy%22 and the 'z' in %22fez%22 count, %0A * but not the 'y' in %22yellow%22 (not case sensitive). %0A * We'll say that a y or z is at the end of a word if there is%0A *  not an alphabetic letter immediately following it. %0A *  (Note: Character.isLetter(char) tests if a char is an alphabetic letter.) %0A *  %0A *  countYZ(%22fez day%22) = 2%0A *  countYZ(%22day fez%22) = 2%0A *  countYZ(%22day fyyyz%22) = 2%0A *  %0A */%0A%0Apublic class countYZTest %7B%0A%0A  public static void main(String%5B%5D args) %7B%0A    countYZTest test = new countYZTest();%0A%0A    System.out.println(%22%3E%22 + test.countYZ(%22fez day%22) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.countYZ(%22day fez%22) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.countYZ(%22day fyyyz%22) + %22%3C%22);%0A  %7D%0A%0A  public int countYZ(String str) %7B%0A    int count = 0;%0A%0A    for (int i = 0; i %3C str.length(); i++) %7B%0A      String c = Character.toString(str.charAt(i));%0A%0A      if (i + 1 == str.length() && %0A          (c.equalsIgnoreCase(%22Z%22) %7C%7C c.equalsIgnoreCase(%22Y%22))) %7B%0A        count += 1;%0A      %7D%0A      else %7B%0A        if ((c.equalsIgnoreCase(%22Z%22) %7C%7C c.equalsIgnoreCase(%22Y%22)) && %0A            !Character.isLetter(str.charAt(i + 1))) %7B%0A          count += 1;%0A        %7D%0A      %7D%0A    %7D%0A%0A    return count;%0A  %7D%0A%0A%7D%0A

add task countYZ