title: Search text file for month, than output information linked to it
body: <p>I need to search a text file, and using the month, then collect information from it.</p>
  
  <p>The archive says information like:</p>
  
  <pre><code>01-Jan-2012 ED521D  4   100 30  1499    M   N Brewer
  </code></pre>
  
  <p>I need to pick out the "jan" and then use the other information. 
  My code looks like:</p>
  
  <pre><code>            String chosenMonth = chooseMonth(); //asks user for month, which is then shortened to first 3 letters
              Scanner entries = readPolicy(); //this brings up the policy.txt
  
              int monthCount = 0;
  
              while (entries.hasNextLine()) {
                  dates = entries.next();
                  String clientDate = dates.substring(3, 6);
  
                  if (clientDate.equalsIgnoreCase(chosenMonth)) {
                      monthCount++; // this is supposed to increment the monthCount everytime it finds the month
                  }
                  refNo = entries.next();
                  itemNo += (entries.nextInt());
                  clientValue = entries.nextInt();
                  clientExcess = entries.nextInt();
                  clientPremium += entries.nextInt();
                  termString = entries.next();
                  clientName = entries.nextLine();
              }
  
              String clientDate = dates.substring(3, 6);
  
  
              if (clientDate.equalsIgnoreCase(chosenMonth)) {
                  int average = getChosenAverage(termString, monthCount, itemNo); //uses terms string to find entries that are marked m, the item no (which is collected and added to everytime it loops through) is then divided by the monthCount.
                  int averagePremium = getChosenAveragePremium(termString, monthCount, clientPremium);//same here except premium is divided by monthCount
                  displayPolicyMonth(chosenMonth, monthCount, average, averagePremium);
  </code></pre>
  
  <p>However its not working and gives me an exception.</p>
  
  <p>The code for the getChosenAveragePremium is:</p>
  
  <pre><code>private static int getChosenAverage(String t, int m, int i) {
      int a = 0;
      char term = t.charAt(0);
  
      if (term == 'A' || term == 'M') {
          a = i / m;
      }
      return a;
  }
  </code></pre>