title: Getting data from an ArrayList to then use in calculations?
body: <p>So I have an assignment, and it requires me to calculate the average of each students marks for each assignment then to calculate the average of each assignment. I am able to calculate the average for each student but i'm having trouble with the average for each assignment and also for the average of averages.
  Then i also need to calculate the standard deviation, we have been given an equation but i'm not sure how to implement it.</p>
  
  <p>The final out put should look like: </p>
  
  <pre><code>Student Name     FAN      Part 1 Part 2 Part 3 Part 4 Mark    Grade
  Adam Adamson     adam0001 85.4   79.8   82.4   86.1   82.77%  DN
  Bethany Bright   brig0001 89.7   85.6   84.2   82.9   84.92%  DN
  Cameron Carlson  carl0001 55.45  49.82  60.4   42.27  50.23%  P
  David Dawson     daws0001 72.6   78.49  80.2   65.88  74.46%  CR
  Evelyn Ellis     elli0001 50.2   35.88  48.41  58.37  46.57%  FA
  Frances Fitz     fitz0001 78.9   75.67  82.48  79.1   78.38%  DN
  Greg Gregson     greg0001 24.3   32.88  29.72  28.4   30.05%  F
  Harriett Hope    hope0001 52.2   58.93  61.5   63.44  60.12%  P
  Ivan Indigo      indi0001 88.4   91.23  90.05  92.46  91.08%  HD
  Jessica Jones    jone0001 82.33  89.74  81.3   84.85  85.84%  HD
                    Average 67.948 67.804 70.066 68.377 68.44%  CR
                                                 StdDev 19.4441
  </code></pre>
  
  <p>I have 3 classes, 2 are just defining the array for the student names&amp;fans and then the other is an array for the student marks. They are not really relevant to the question. </p>
  
  <p>I am basically running everything in my main class because that was the only way i could get it to format properly and i'm running out of time.</p>
  
  <pre><code>public class TopicManagement 
  {
  
  public static void main(String[] args) throws IOException 
  {   
  
      System.out.println("Hello, Welcome to the Student Assesment Calculator");
                                       //added an extra tab before the FAN to adjust for longer names
      System.out.println("Student Name \t\tFAN \t\tScore 1\tScore 2\tScore 3\tScore 4\tMark\tGrade");
  
  
      DecimalFormat df2 = new DecimalFormat("#.##");  //rouding to 2 decimal places
      DecimalFormat df3 = new DecimalFormat("#.###"); //rounding to 3 decimal places
  
      String [][] marks = StudentMarks.StudentMarks();  //marks Arrays is the students assignment results
      String [][] nameFan = Student.Student();          //nameFan is the array containing student names and FANs
  
  
      for (int row = 0; row &lt; marks.length; row++)
      {                                          //ROW,COL
          double score1 = Double.parseDouble(marks[row][2]);  //parsing the data from the array into a double
          double score2 = Double.parseDouble(marks[row][3]);
          double score3 = Double.parseDouble(marks[row][4]);
          double score4 = Double.parseDouble(marks[row][5]);
  
          double average = score1*0.1 + score2*0.4 + score3*0.2 + score4*0.3;            
          String grade = null;
  
  
  
          if (85&lt;=average &amp;&amp; average&lt;101) //if average is between 85 and 100
          {
              grade = "HD"; //High Distinction
          }
          else if (75&lt;=average &amp;&amp; average&lt;85) //if average if between 75 and 84
          {
              grade = "DN"; //Distinction
          }
          else if (65&lt;=average &amp;&amp; average&lt;75) //if average is between 65 and 74
          {
              grade = "CR"; //Credit
          }
          else if (50&lt;=average &amp;&amp; average&lt;65) //if average is between 50 and 64
          {
              grade = "P"; //Pass
          }
          else if (45&lt;=average &amp;&amp; average&lt;50) //if average is between 45 and 49
          {
              grade = "FA"; //Fail Academic
          }
          else if (0&lt;=average &amp;&amp; average&lt;45) //if average is between 0 and 44
          {
              grade = "F"; //Fail
          }
  
  
  
          System.out.println(nameFan[row][0] + "\t\t" + nameFan[row][1] + "\t" + marks[row][2] + "\t" + marks[row][3] + "\t" + 
                             marks[row][4] + "\t" + marks[row][5] + "\t" + df2.format(average) + "%\t" + grade);
      }
  
       for (int col = 0; col &lt; marks.length; col++)
       {
          ArrayList average1 = new ArrayList(10);
          ArrayList average2 = new ArrayList(10);
          ArrayList average3 = new ArrayList(10);
          ArrayList average4 = new ArrayList(10);
  
          double part1 = Double.parseDouble(marks[col][2]);
          double part2 = Double.parseDouble(marks[col][3]);
          double part3 = Double.parseDouble(marks[col][4]);
          double part4 = Double.parseDouble(marks[col][5]);
  
          average1.add(part1);
          average2.add(part2);
          average3.add(part3);
          average4.add(part4);
  
          double average = avera;
          String grade = null;
  
          if (85&lt;=average &amp;&amp; average&lt;101) //if average is between 85 and 100
          {
              grade = "HD"; //High Distinction
          }
          else if (75&lt;=average &amp;&amp; average&lt;85) //if average if between 75 and 84
          {
              grade = "DN"; //Distinction
          }
          else if (65&lt;=average &amp;&amp; average&lt;75) //if average is between 65 and 74
          {
              grade = "CR"; //Credit
          }
          else if (50&lt;=average &amp;&amp; average&lt;65) //if average is between 50 and 64
          {
              grade = "P"; //Pass
          }
          else if (45&lt;=average &amp;&amp; average&lt;50) //if average is between 45 and 49
          {
              grade = "FA"; //Fail Academic
          }
          else if (0&lt;=average &amp;&amp; average&lt;45) //if average is between 0 and 44
          {
              grade = "F"; //Fail
          }
  
          System.out.println("\t\t\tAverage" + " \t" + average1 + "\t" + average2 + "\t" + average3 + "\t" +
                                              average4 + "\t" + df2.format(average) + "%\t" +  grade);
        }
    }//end of method
  }//end of class
  </code></pre>
  
  <p>this outputs:</p>
  
  <pre><code>Hello, Welcome to the Student Assesment Calculator
  Student Name        FAN         Score 1 Score 2 Score 3 Score 4 Mark    Grade
  Adam Adamson        adam0001    85.4    79.8    82.4    86.1    82.77%  DN
  Bethany Bright      brig0001    89.7    85.6    84.2    82.9    84.92%  DN
  Cameron Carlson     carl0001    55.45   49.82   60.4    42.27   50.23%  P
  David Dawson        daws0001    72.6    78.49   80.2    65.88   74.46%  CR
  Evelyn Ellis        elli0001    50.2    35.88   48.41   58.37   46.56%  FA
  Frances Fitz        fitz0001    78.9    75.67   82.48   79.1    78.38%  DN
  Greg Gregson        greg0001    24.3    32.88   29.72   28.4    30.05%  F
  Harriett Hope       hope0001    52.2    58.93   61.5    63.44   60.12%  P
  Ivan Indigo         indi0001    88.4    91.23   90.05   92.46   91.08%  HD
  Jessica Jones       jone0001    82.33   89.74   81.3    84.85   85.84%  HD
  </code></pre>
  
  <p>The standard deviation we were given was (hopefully you can interpret):</p>
  
  <pre><code>SD = sqrt(sum of(each value in the data set - mean of all data in the data set)^2)
  divided by       number of values in the data set
  </code></pre>
  
  <p>I'm not sure how to go about getting those last two lines, the average, and the standard deviation. I think what i have at the moment is each assignment being scanned into an ArrayList, so my question is, how do i then get the data in that array list to then be able to calculate the average <strong>OR</strong> how would you calculate the average? i'm open to any suggestions and would appreciate if you could give an example through code.</p>
  
  <p>Thanks.</p>
  
  <pre><code>                                     **EDIT**
  </code></pre>
  
  <p>Ok, so i've worked out how to do the averages. I've used a method for each assignment and then i call it in the main method, this is the first of the 4 methods:</p>
  
  <pre><code>public static double CalculateAverage1() throws IOException
  {
      String [][] marks = StudentMarks.StudentMarks();
  
      double sum = 0;
      int col = 0;
      for(col = 0; col &lt; marks.length; col++)
      {         
          double part1 = Double.parseDouble(marks[col][2]);
  
              sum += part1;
  
      }
      return sum/col;
  }
  </code></pre>
  
  <p>I'm still having trouble with the Standard Deviation.</p>
  
  <p>I can't even manage to work it out using my calculator. Please help, or at least stear me in the right direction.</p>
  
  <p>Thankyou!</p>