title: Java, Constructor w/ array as an argument & user input from Driver
body: <p>I'm pretty new to java and I seem to get held up on small things, especially when it comes to methods with parameters.</p>
  
  <p>This is for a class assignment, mainly about exception handling which I believe I got correct.  I know what's going wrong I just don't know how to fix it.</p>
  
  <p>Let me explain.  Assignment asks us to set up a constructor that takes a double array as an argument (for test scores) &amp; throw an IllegalArgumentException if a score is outside of the range 0-100.  The program is calculating the average of the test scores correctly, but my issue is (I think) nothing is actually being passed into the constructor so that the constructor can look for an exception.  I believe it's just running through the constructor but not passing anything into it that is why the exception is not getting thrown when I pass in a negative number.  </p>
  
  <p>I don't know what I'm doing wrong, any help is greatly appreciated!</p>
  
  <pre><code>/**Write a class named TestScores. The class constructor should 
   * accept an array of test scores as its argument. The class should 
   * have a method that returns the average of the test scores. If any
   * test score in the array is negative or greater than 100, the class
   * should throw an IllegalArgumentException. Demonstrate the class in a program.
  */
  
  public class TestScores {
  
     private double testScores[];
     ScoresDemo TD = new ScoresDemo();
  
      public TestScores(double scores[]) {
          testScores = scores;
          try {
              for(int i = 0; i &lt; testScores.length; i++) {
                  if(scores[i] &lt; 0 || scores[i] &gt; 100) {
                      throw new IllegalArgumentException("Test scores must be between 0 and 100");
                  }
                  else {
                      testScores[i] = scores[i];
                  }
              }
          }catch(IllegalFormatException ex) {
              System.out.println(ex);
          }
     }
  
      public double averageScores() {
          double average = 0;
          int count = testScores.length;
          int sum = 0;
              for(int i = 0; i &lt; testScores.length; i++) {
                  sum += testScores[i];
              }
           average = sum / count;
           return average;
      } 
  }
  </code></pre>
  
  <p>"DRIVER" CLASS</p>
  
  <pre><code>public class ScoresDemo {
  
      public static void main(String[] args) {
          double testScores[] = new double [5];
          TestScores scores = new TestScores(testScores);
          Scanner scan = new Scanner(System.in);
  
          for(int i = 0; i &lt; testScores.length; i++) {
              System.out.println("Enter some test scores: ");
              testScores[i] = scan.nextDouble();
          }
          System.out.println("The average of the test scores is " + scores.averageScores());
      }
  }
  </code></pre>