title: using scanner class to average numbers in java
body: <p>I am using a scanner class to average numbers together. I am using a method to do the averaging. I do not want the program to run if there are more than 20 args. I cant seem to get this to work. I am very new at java and trying to learn. </p>
  
  <p>I appreciate any help I can get. Thanks! </p>
  
  <pre><code>import java.util.Scanner;
  
  class programTwo {
  
  
      public static void main (String[] args) {
  
          Scanner scan = new Scanner(System.in);
          double x = 0.00d;
  
          if (args != null) {
              System.out.println ("Enter your numbers to be averaged. Remember no more than 20!:");
              x = scan.nextInt();
  
              if (x &lt;= 21) {
                  System.out.println("Please do not add more than 20 numbers");   
              }  
         } else {
         }
  
      }
  
      public double average(double [] values) {
          double average = 0.0;
          if ((values != null) &amp;&amp; (values.length &gt; 0)) {
              for (double value : values) {
                  average += value;
              }
          average /= values.length; 
          }
          return average;
      }
  
  }
  </code></pre>