SHARE
TWEET

Untitled

advictoriam Jan 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Grades
  2. {
  3.    /**
  4.       This method examines the two-dimensional array of integers
  5.       identified by the first parameter, whose length (number of rows,
  6.       also the number of students) is the second parameter, while the
  7.       three columns in the array represent the scores for three
  8.       different tests.
  9.       The test scores for each student (one row of three grades) are
  10.       combined to find the average score for each student.  The integer
  11.       returned is the number of students with a test average less than 70.
  12.       @param numStudents, the number of students who took the three tests
  13.       @param theArray, a 2-D array of integer scores
  14.       @return, the number of test averages below a score of 70
  15.    */
  16.    public static int testAverage(double[][] theArray, int numStudents)
  17.    {
  18.       int NUM_TESTS = 3;
  19.      
  20.       int count = 0;
  21.      
  22.       double[] averages = new double[numStudents];
  23.       for(int i = 0; i < numStudents; i++)
  24.       {
  25.          averages[i] = (theArray[i][0]+theArray[i][1]+theArray[i][2])/3;
  26.       }
  27.    
  28.       for(double a : averages)
  29.       {
  30.          if(a < 70){count++;}
  31.       }
  32.      
  33.       return count;
  34.    }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top