Using the above code add a method that takes in three arrays, one for student names, one for final test marks and a last one for assignment mark. The method should then calculate the students qualifying mark (a student needs 50 or more to qualify) using the following weights: 40% of the test and 60% of the assignment, finally print out whether the person qualified or not. [10]
public class Main {
public static void checkQualifies(String[] names, int[][] testMarks, int[] assignmentMarks) {
double total;
for (int i = 0; i < names.length; i++) {
total = 0;
System.out.print(names[i] + " ");
for (int j = 0; j < testMarks[i].length; j++) {
total += testMarks[i][j];
System.out.print(testMarks[i][j] + " ");
}
total /= testMarks[i].length;
total *= 0.4;
System.out.print(assignmentMarks[i] + " ");
total += (0.6 * assignmentMarks[i]);
if (total >= 50) {
System.out.println("Allowed");
} else {
System.out.println("Denied");
}
}
}
public static void main(String[] args) {
checkQualifies(new String[]{"King", "John"}, new int[][]{{59, 85}, {52, 45}}, new int[]{75, 48});
}
}
Comments
Leave a comment