@@ -0,0 +1,910 @@
+package codingbat.string2;%0A%0A/*%0A * Return the number of times that the string %22code%22 appears anywhere %0A * in the given string, except we'll accept any letter for the 'd', %0A * so %22cope%22 and %22cooe%22 count. %0A * %0A * countCode(%22aaacodebbb%22) = 1%0A * countCode(%22codexxcode%22) = 2%0A * countCode(%22cozexxcope%22) = 2%0A * %0A */%0A%0Apublic class CountCodeTest %7B%0A%0A  public static void main(String%5B%5D args) %7B%0A%0A    CountCodeTest test = new CountCodeTest();%0A%0A    System.out.println(%22%3E%22 + test.countCode(%22aaacodebbb%22) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.countCode(%22codexxcode%22) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.countCode(%22cozexxcope%22) + %22%3C%22);%0A  %7D%0A%0A  public int countCode(String str) %7B%0A    String word = %22%22;%0A    int counter = 0;%0A    %0A    for (int i = 0; i %3C str.length()-3; i++) %7B%0A      word = str.substring(i, i+4);%0A      if (word.matches(%22co%5Ba-zA-Z%5De%22)) %7B%0A        counter += 1;%0A      %7D%0A    %7D%0A    %0A    return counter;%0A  %7D%0A%0A%7D%0A

add task countCode