Write a method that implements a linear search.

To get started, download the class Main.java (also below) Update the file by replacing the /* missing code */ with your own implementation of the method countLetter.

countLetter accepts as input an ArrayList of Strings and a letter, stored in a String. The method returns the number of Strings in the input ArrayList that start with the given letter. Your implementation should use a linear search algorithm that ignores the case of the Strings in the ArrayList.

Test your code by running the main method and verifying that your output matches the Sample Run that follows.

Sample Run

[Zebra, Aardvark, Emu, Hippo, Alligator, Lion, Giraffe, Seal, Tiger, Elephant]
A: 2
B: 0
C: 0
L: 1
T: 1
a: 2
b: 0
c: 0
l: 1
t: 1 Main.java
/*
   * Amplify AP CS MOOC - Term 2, Lesson 14 
   */
   import java.io.*;
   import java.util.*;
class Main
   {
 /*
   * Returns the number of Strings in the input list that start with the given
   * letter. Implementation should use linear search, and ignore the case of
   * the input letter.
   */
   public static int countLetter(ArrayList<String> list, String letter)
   {
   /* missing code */
   }
 public static void main(String str[]) throws IOException
   {
   /*
   * Initialize an ArrayList of animals called zoo.
   */
   ArrayList<String> zoo = new ArrayList<String>();
   zoo.add("Zebra");
   zoo.add("Aardvark");
   zoo.add("Emu");
   zoo.add("Hippo");
   zoo.add("Aligator");
   zoo.add("Lion");
   zoo.add("Giraffe");
   zoo.add("Seal");
   zoo.add("Tiger");
   zoo.add("Elephant");
 /*
   * Print the contents of the zoo.
   */
   System.out.println(zoo);
 /*
   * Print the output from calling countLetter with various letters. For
   * example, countLetter (zoo, "e") should return 2 while
   * countLetter(zoo, "W") should return 0.
   */
   System.out.println("A: " + countLetter(zoo, "A"));
   System.out.println("B: " + countLetter(zoo, "B"));
   System.out.println("C: " + countLetter(zoo, "C"));
   System.out.println("L: " + countLetter(zoo, "L"));
   System.out.println("T: " + countLetter(zoo, "T"));
 System.out.println("a: " + countLetter(zoo, "a"));
   System.out.println("b: " + countLetter(zoo, "b"));
   System.out.println("c: " + countLetter(zoo, "c"));
   System.out.println("l: " + countLetter(zoo, "l"));
   System.out.println("t: " + countLetter(zoo, "t"));
   }
   }