<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="serif">Overnight I got a few emails asking me for help
      on how to connect the data between the array containing the stations
      to the array containing the state info.  Here is one way to do
      it...<br>
      <br>
      Lets assume that you have done the following.   You have a
      complete array of all the stations; each element of this array is
      a Station objects (with instance variables for stationID and
      stateID that are both strings).<br>
      <br>
      Using your stations array you have created an array of state
      information; each element of this array is stored as a unique
      State object (with instance variables for stateID,  the sum of the
      readings, and the number of readings.  While your array elements
      will have stateID information, the other two instance variables
      should be zero.  So at this point you have completed all of the
      work associated with building the arrays for your program.  You
      have one array that will serve as a LOOKUP TABLE and another array
      that will actually hold the data you process.<br>
      <br>
      <b>Verify that you have all this done correctly before continuing!</b><br>
      <br>
      If you have gotten this far, you are now ready to read the
      daily.txt file and start populating the state array with
      temperature data.  The first thing you should do in this step is
      make sure that you can read the daily.txt file and extract the
      stationID and temperature from each line.  Once you know that you
      can do this correctly the proceed as follows:<br>
      <br>
    </font>
    <ol>
      <li><font face="serif">For each line of the daily text file read
          the stationID and the temperature</font></li>
      <li><font face="serif">By searching through each entry in your
          stations array, compare the stationID you just read from the
          daily.txt file with the information in your stations array to
          find the array index where the stationID is found.  <br>
        </font></li>
      <li><font face="serif">Once you know the index, you can extract
          the stateID into a variable with something like...</font></li>
    </ol>
    <tt>                    found = false;</tt><tt><br>
    </tt><tt>                    index = 0;</tt><tt><br>
    </tt><tt>                    state = "";</tt><tt><br>
    </tt><tt>                    while ( !found &amp;&amp; index &lt;
      stations.length ) {</tt><tt><br>
    </tt><tt>                         if (
      stations[index].getID().equals(stationID) ) {</tt><tt><br>
    </tt><tt>                             found = true;</tt><tt><br>
    </tt><tt>                             state =
      stations[index].getState();</tt><tt><br>
    </tt><tt>                         }</tt><tt><br>
    </tt><tt>                         index++;</tt><tt><br>
    </tt><tt>                    }<br>
      <br>
    </tt>        where getID() and getState() are methods inside my
    Station class.<br>
    <ol start="4">
      <li>Once you have used your LOOKUP TABLE to resolve the state name
        for the stationID, you now need to find the index of the
        location of the state in your array of states.  You will do
        something very similar to what I did above to locate the
        position of the state in the array of states and then, once you
        have the index of the location in the state array, call your
        method to add the temperature reading.  Something like..</li>
    </ol>
    <p><span id="OLK_SRC_BODY_SECTION"><span style="font-family:
          Calibri, sans-serif;">                             <tt>stateData[index].addTemp(temp);</tt></span></span></p>
    <p>        Again, this assumes that in my State class I have an
      addTemp() method defined.</p>
    <ol start="5">
      <li>Read the next line of the 400000+ lines in the daily.txt file
        and do the whole thing again...</li>
    </ol>
    <br>
    As always, let me know where you get stuck.    <br>
    <span id="OLK_SRC_BODY_SECTION"><span style="font-family: Calibri,
        sans-serif;"></span></span>
    <p><br>
    </p>
    <font face="serif"><br>
    </font>
    <pre class="moz-signature" cols="72">-- 
Andrew J. Pounds, Ph.D.  (<a class="moz-txt-link-abbreviated" href="mailto:pounds_aj@mercer.edu">pounds_aj@mercer.edu</a>)
Professor of Chemistry and Computer Science
Mercer University,  Macon, GA 31207   (478) 301-5627
<a class="moz-txt-link-freetext" href="http://faculty.mercer.edu/pounds_aj">http://faculty.mercer.edu/pounds_aj</a>
</pre>
  </body>
</html>