title: How do I correctly get the largest and smallest numbers in a sequence of numbers?
body: <p>I'm supposed to get the smallest and largest number out of a sequence of numbers. I know my method body for each method is probably not right. Any help?</p>
  
  <pre><code>public class DataSet
  {
    private int sum;
    private int count;
    private int largest;
    private int smallest;
  
    public DataSet()
     {
     sum = 0;
     count = 0;
     largest = 0;
     smallest = 0;
     }
  
   public void addValue(int x)
    {
     sum = sum + x;
     count++;
    }
  
   public int getSum()
   {
     return sum;
   }
  
   public double getAverage()
   {
     double average = sum/count;
     return average;
   }
  
   public int getLargest()
   {
     int largest = Integer.MAX_VALUE;//not giving right answer, don't know how to use
     return largest;
   }
  
    public int getSmallest()
   {
     int smallest = Integer.MIN_VALUE;//not giving right answer, don't know how to use
     return smallest;
    }
  }
  </code></pre>
  
  <hr>
  
  <p>Here is the tester class if it is needed, although I don't think the problem lies here.</p>
  
  <pre><code> public class DataSetTester
   {  
     public static void main(String[] args)
      {
      DataSet myData = new DataSet();
      myData.addValue(100);
      myData.addValue(5);
      myData.addValue(4);
      myData.addValue(2);
  
      System.out.println("Sum = " + myData.getSum());
      System.out.println("Average = " + myData.getAverage());
      System.out.println("Largest value = " + myData.getLargest());
      System.out.println("Smallest value = " + myData.getSmallest());
     }
     }
  </code></pre>