title: I m reading an array from a text file, then i should capitalize, count ocurrences of each name to then display all the info
body: <p>I need to be able to ask user for file name, then display the names formatted. </p>
  
  <p>Write a java program that reads a sequence of names (first name followed by last name, separated by at least one space) from a text file and:</p>
  
  <p>Displays the list of names (last name followed by a comma, followed by one space, followed by first name) that are read from the input file in ascending order. Each first name and last name must be capitalized (first letter in upper case and the remaining letters in lower case). First and last names must be lined up as per the example below.</p>
  
  <p>For each first name in the file, displays the number of times that the first name appears in the file. (i.e. firstName: count). This list of first names must be displayed in the ascending order of the first names. Each first name must be capitalized (first letter in upper case and the remaining letters in lower case) and displayed only once. First names and counts must be lined up as per the example below.</p>
  
  <p>For each last name in the file, displays the number of times that the last name appears in the file. (i.e. lastName: count). This list of last names must be displayed in the ascending order of the last names. Each last name must be capitalized (first letter in upper case and the remaining letters in lower case) and displayed only once. Last names must be lined up as per the example below.</p>
  
  <p>For each name in the file, (last name followed by a comma, followed by one space, followed by first name) displays the number of times that the names appears in the file. (i.e. name: count). This list of names must be displayed in the ascending order of the names. All first and last names must be capitalized. Each name must be displayed only once. First names, last names and counts must be lined up as per the example below.</p>
  
  <p>Displays the list of unique names (last name followed by a comma, followed by one or more spaces, followed by first name) in ascending order. First names and last names must be lined up as per the example below.</p>
  
  <p>Writes the list of unique names (last name followed by a comma, followed by one or more spaces, followed by first name) in ascending order to a text file. First names and last names be lined up similar to display in item 5.</p>
  
  <p>The program must ask the user to provide the names of the input and output files</p>
  
  <p>The output should be:</p>
  
  <pre class="lang-none prettyprint-override"><code> Enter the name of the input file
  
   input.txt
  
   ******* All Names *********
   Beres, Kirsten
   Beres, Kirsten
   Beumer, Gretta
   Hutt, Colette
   Hutt, Shawanda
   Jones, Colette
   Jones, Marcia
   Koenig, Gerri
   Means, Tijuana
   Montilla, Adriana
   Montilla, Adriana
   Montilla, Adriana
   Montilla, Adriana
   Mossman, Emmanuel
   Sapienza, Colette
   Sapienza, Colette
   Shover, Neva
   Stanfill, Marcia
  
   ******* First Names count*********
   Adriana 4
   Colette 4
   Emmanuel 1
   Gerri 1
   Gretta 1
   Kirsten 2
   Marcia 2
   Neva 1
   Shawanda 1
   Tijuana 1
   ******* Last Names count *********
   Beres 2
   Beumer 1
   Hutt 2
   Jones 2
   Koenig 1
   Means 1
   Montilla 4
   Mossman 1
   Sapienza 2
   Shover 1
   Stanfill 1
   ******* All Names count*********
   Beres, Kirsten 2
   Beumer, Gretta 1
   Hutt, Colette 1
   Hutt, Shawanda 1
   Jones, Colette 1
   Jones, Marcia 1
   Koenig, Gerri 1
   Means, Tijuana 1
   Montilla, Adriana 4
   Mossman, Emmanuel 1
   Sapienza, Colette 2
   Shover, Neva 1
   Stanfill, Marcia 1
   ******* All Unique Names *********
   Beres, Kirsten
   Beumer, Gretta
   Hutt, Colette
   Hutt, Shawanda
   Jones, Colette
   Jones, Marcia
   Koenig, Gerri
   Means, Tijuana
   Montilla, Adriana
   Mossman, Emmanuel
   Sapienza, Colette
   Shover, Neva
   Stanfill, Marcia
  
   Enter the name of the output file
   output.txt
  </code></pre>
  
  <p>This is what I have so far but I feel lost, cannot find a way to capitalize and count. I have tried several things but nothing seems to work.</p>
  
  <pre><code>public static void getNames(ArrayList&lt;String&gt; fn,
                              ArrayList&lt;String&gt; ln) throws IOException {
  
      Scanner kb = new Scanner(System.in);
  
      System.out.print("What is the name input file? ");
  
      String fileName = kb.next();
  
      File inpFile = new File(fileName);
      Scanner in = new Scanner(inpFile);
  
      while (in.hasNext()) {
          String firstName = in.next();
          String lastName = in.next();
          fn.add(firstName);
          ln.add(lastName);
      }
  }
  
  public static void display(ArrayList&lt;String&gt; names) {
      for (int i = 0; i &lt; names.size(); i++) {
  
          System.out.println(names.get(i));
      }
  }
  
  public static void capitalize(ArrayList&lt;String&gt; firstName) {
      for (int i = 0; i &lt; firstName.size(); i++) {
          firstName.set(i; toCapital(firstName.get(i)));
      }
  }
   /*
   * public static void capitalize(ArrayList&lt;String&gt; names) {
   * for (int i = 0; i &lt; names.size(); i++){
   * names.set(i,toCapital(names.get(i)));
   * }
   * }
   */
  //public static String toCapital (String name){
  //String.toUpperCase(name.charAt(0)) +
  
  //String.toLowerCase(name.substring(1));
  
  //return j;
  //}
  public static void main(String[] args) throws IOException {
      // TODO code application logic here
      ArrayList&lt;String&gt; first = new ArrayList&lt;&gt;();
      ArrayList&lt;String&gt; last = new ArrayList&lt;&gt;();
      getNames(first, last);
      //display(first);
      //display(last);
      ArrayList&lt;String&gt; allNames = new ArrayList&lt;&gt;();
      for (int i = 0; i &lt; first.size(); i++) {
          allNames.add(last.get(i) + ", " + first.get(i));
      }
  
      display(allNames);
  }
  </code></pre>
  
  <p>This is the content of the input file:</p>
  
  <pre>colette Sapienza
  gretta Beumer
  EMManuel Mossman
  Colette Sapienza
  marcia Jones
  Shawanda Hutt
  Adriana monTILla
  adriana montilla
  Adriana Montilla
  Colette Jones
  Colette Hutt
  Marcia Stanfill
  NeVa shover
  tijuana Means
  Adriana Montilla
  gerri KoeNig
  Kirsten beres
  Kirsten Beres
  </pre>