title: calculating average of random integers in an array
body: <p>I need to generate a specified number of random integers between any
  two values specified by the user (example, 12 numbers all between 10 and 20), and then calculate the average of the numbers. 
  The problem is if I ask for it to generate 10 numbers, it will only generate 9 (shown in output.) 
  Also, if I enter a max range of 100 and min range of 90, the program will still generate #'s like 147, etc that are over the max range... did I mess up the random number generator? Can someone help? </p>
  
  <p>Here is the code I have so far: </p>
  
  <pre><code>public class ArrayRandom
  {
  static Console c;           // The output console
  
  public static void main (String[] args)
  {
      c = new Console ();
      DecimalFormat y = new DecimalFormat ("###.##");
  
      c.println ("How many integers would you like to generate?");
      int n = c.readInt (); 
      c.println ("What is the maximum value for these numbers?");
      int max = c.readInt ();
      c.println ("What is the minimum value for these numbers?");
      int min = c.readInt ();
  
      int numbers[] = new int [n]; 
      int x;
      double sum = 0; 
      double average = 0; 
  
      //n = number of random integers generated
      for (x = 1 ; x &lt;= n-1 ; x++) 
      {
  
          numbers [x] = (int) (max * Math.random () + min); 
      }
  
      for (x = 1 ; x &lt;= n-1 ; x++) 
      {
          sum += numbers [x]; 
          average = sum / n-1); 
  
      }
  
      c.println ("The sum of the numbers is: " + sum); 
      c.println ("The average of the numbers is: " + y.format(average)); 
  
      c.println ("Here are all the numbers:"); 
      for (x = 1 ; x &lt;= n-1 ; x++)  
  {
          c.println (numbers [x]); //print all numbers in array
  }
  
  
  } // main method
  } // ArrayRandom class
  </code></pre>