Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Grades
- {
- /**
- This method examines the two-dimensional array of integers
- identified by the first parameter, whose length (number of rows,
- also the number of students) is the second parameter, while the
- three columns in the array represent the scores for three
- different tests.
- The test scores for each student (one row of three grades) are
- combined to find the average score for each student. The integer
- returned is the number of students with a test average less than 70.
- @param numStudents, the number of students who took the three tests
- @param theArray, a 2-D array of integer scores
- @return, the number of test averages below a score of 70
- */
- public static int testAverage(double[][] theArray, int numStudents)
- {
- int NUM_TESTS = 3;
- int count = 0;
- double[] averages = new double[numStudents];
- for(int i = 0; i < numStudents; i++)
- {
- averages[i] = (theArray[i][0]+theArray[i][1]+theArray[i][2])/3;
- }
- for(double a : averages)
- {
- if(a < 70){count++;}
- }
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement