title: How to average random numbers in java?
body: <p>thanks in advance for any help I'm in an intro to java class and our home work was to generate 10 random numbers between 1&amp;50 which I got and then average the generated numbers. I can't figure out how to average them here's what I have. Is there a way to store each random number as a variable?</p>
  
  <pre><code>public class randomNumberGen
  {
       public static void main(String [] args)
       {
           Random r=new Random();
  
           for (int i=1;i&lt;=10;i++){
               System.out.println(r.nextInt(50));
               System.out.println();
                int average = (i/4);
  
                System.out.println("your average is"+average);
  
           }
       }
  }
  </code></pre>