title: Java help: How to find largest number in scanned in file?
body: <p>I need to find the sum, count of, number of evens, number of odds, largest, smallest, and average of the numbers of the scanned file.  I've done everything except largest/smallest.
  When the program runs, the largest/smallest equals the count instead of producing the largest/smallest value the count encounters.</p>
  
  <p><strong>EDIT: I understand that largest/smallest are being compared to count.  I now understand that mistake.  I don't understand how to find the smallest/largest value that count encounters.</strong></p>
  
  <p>Here is what I've done:
  <strong>NOTE:</strong> All code before while loop was prewritten by my professor and that code cannot be tampered with or altered in any way. Not allowed to use arrays either.</p>
  
  <pre><code>int count=0,sum=0, largest=Integer.MIN_VALUE,smallest=Integer.MAX_VALUE, evens=0, odds=0;
          double average=0.0;
  
          while (infile.hasNext())
          {
              count += 1;
              sum += infile.nextInt();
              average = sum/count;
              if (count &gt; largest)
                  largest = count;
              if (count &lt; smallest)
                  smallest = count;
              if (sum%2 != 0)
                  odds++;
              else
                  evens++;
  
          }
          infile.close();
  </code></pre>