title: Finding largest and smallest numbers within a file using Java
body: <p>As part of this problem I needed to find:</p>
  
  <ul>
  <li>the amount of numbers (count)</li>
  <li>the sum of the numbers (sum)</li>
  <li>the average of the numbers (average)</li>
  <li>which numbers are even (evens)</li>
  <li>which numbers are odd (odds)</li>
  </ul>
  
  <p>the last two things I need to find are the largest and smallest values.</p>
  
  <p>My teacher wrote the base code already:</p>
  
  <pre><code>Scanner infile = new Scanner ( new FileReader(args[0]) );
  int count=0,sum=0, largest=Integer.MIN_VALUE,smallest=Integer.MAX_VALUE, evens=0, odds=0;
  double average=0.0;
  
  while (infile.hasNext())
  </code></pre>
  
  <p>I've written the code for the listed variables within the while loop but I can't figure out what to do about the largest and smallest value.</p>
  
  <p>I have tried doing this within the while loops:</p>
  
  <pre><code>if (count &gt; largest)
     largest = count;
  
  if (count &lt; smallest)
     smallest = count;
  </code></pre>
  
  <p>The idea being that while the while loop iterates it will compare the number it passes against the largest value and it will match the largest one it finds in the count against largest and if the number it find is larger than largest, that becomes the new largest.  Same idea for smallest.</p>
  
  <p>It is not working though.  What should I do?</p>
  
  <p>I'm not sure if you guys need this but this is the code I wrote for the count within the while loop:</p>
  
  <pre><code>count += 1;
  </code></pre>
  
  <p>What should I do?</p>
  
  <p>EDIT/ADD ON:
  I figured you guys should see everything else I've actually done within the while loops:</p>
  
  <pre><code>while (infile.hasNext())
      {
          count += 1;
          sum += infile.nextInt();
          average = sum/count;
          if (sum%2 != 0)
              odds++;
          else
              evens++;
      }
  </code></pre>