Java program Using the above code add a method that takes in three arrays, one f
ID: 3720242 • Letter: J
Question
Java program
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]
Use the below format for you print out:
Name Test Assignment Final Examination
-------- ------- ---------------- ------- ------------------
King 59 85 75 Allowed
John 52 45 48 Denied
Sample Test 1:
Enter the total number of students:
3
Enter name:
koko
Enter name:
jojo
Enter name:
momo
Enter mark for Test 1:
78
Enter mark for Test 2:
65
Enter mark for Test 3:
70
Enter mark for Test 1:
55
Enter mark for Test 2:
56
Enter mark for Test 3:
89
Enter mark for Test 1:
45
Enter mark for Test 2:
25
Enter mark for Test 3:
38
Enter assignment Mark:
66
Enter assignment Mark:
86
Enter assignment Mark:
70
Name Test01 Test02 Test03 Final
------ ------ ------ ------ -----
koko 78 65 70 71
jojo 55 56 89 67
momo 45 25 38 36
-----------------QUALIFYING RESULTS-----------------
Name Test Assignment Final Examination
---- ---- ----------- ------ ------------
koko 71 66 68 Allowed
jojo 67 86 78 Allowed
momo 36 70 56 Allowed
Explanation / Answer
public class Student
{
public static void qualify(String[] name, double[] test , double[] assignment)
{
int i;
System.out.printf("%20s %10.2f %10.2f %10.2f %20s ", "Name" , "Test", "Assignment" , "Final" , "Examination");
for( i = 0 ; i < name.length ; i++ )
{
System.out.printf("%20s %10.2f %10.2f %10.2f", name[i] , test[i] , assignment[i]);
// calculate final marks
double final_marks = 0.4 * test[i] + 0.6 * assignment[i];
if( final_marks >= 50 )
System.out.println("Allowed");
else
System.out.println("Denied");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.