/**
 * 3D array code: add third term dimension to student/quiz 2D array
 * @author CPSC 111 Jan 2010 class, in array order of row/column seating in the lecture hall!
 * @date Mon Mar 15 2010
 */
public class ArrayTest
{
  public static void main(String[] args)
  {
	  //double[][] termaverage; 
	  // one idea: have multiple 2D arrays of scores, one for each term. hmm, probably not the best way.
	  // let's try a 3D array of scores!
	  double[][][] scores = {
			  {{34, 46, 24, 33, 55},{88,67,89,43,88},{45,67,89,90,33}},
			  {{95, 82, 13, 96,99},{51, 68, 63, 57,33}, {73, 71, 84, 78,76}}
	  };
 
    double average;

    // used to have outer loop of student rows, and inner loop of quiz columns. what is it now?
    // now row is a term? stopped here at end of class
    
    // here's where we control looping row by row (student by student)
    for (int row = 0; row < scores.length; row++)
    {
      average = 0;
      // and here's where we control looping through the columns
      // (i.e., quiz scores) within each row
      for (int col = 0; col < scores[row].length; col++)
      {
    	  	for (int stack = 0; stack < scores[row][col].length; stack++)
    	  	{
    	  		average = average + scores[row][col][stack];
    	  	}
    	      average = average / scores[row][col].length;
      }
      System.out.println("average of row " + row + " is " + average);
    }
  }
}