title: Array Sum & Average in Java
body: <p>I have a homework assignment where I have to create an array, sum the elements in the array, and then find the average of the elements in the array, but I have to do it in the same method as the summing method. </p>
  
  <p>This is what I have so far, I've looked in my book and put that in my code, but it won't compile right. </p>
  
  <pre><code>class SumArray{
     public static void main(String args[]){
         double[] array = {7,8,9,10,11,12,13};
        sumArray(array);
     }
  
  
     public static double sumArray(double[] array){
        double sum = 0;
        for ( int i = 0; i &lt; array.length; i++){
           sum += array[i];
           //System.out.println("Sum is = " + sum);
           }
        //System.out.println("Sum is = " +sum);
        //after summing then get average
        return sum;
  
      double average = sum/array.length;
  
      System.out.println("Average value of array element is " + average); 
      return average; 
      }      
  }
  </code></pre>