Create a java program that initialize a two dimensional array with the continuou
ID: 3713363 • Letter: C
Question
Create a java program that initialize a two dimensional array with the continuous assessment marks used to determine the semester mark for PRG510S exam qualification, The system should also create an array of student names in correspondence to the marks (Note: the appropriate weights of each individual assessment are given under corresponding headings and both the marks and student names are read from the user input).
test1
(Weight 20%)
test2
(Weight 20%)
labs
(Weight 20%)
in_class exercise
(Weight 10%)
assignment
(Weight 30%)
John
50
60
79
89
63
Harry
41
52
68
56
40
Uushona
30
20
52
38
47
Sililo
23
33
45
19
27
Enter class size: 4
Enter student name:John
Enter John’s semester marks: 50 60 79 89 63
Enter student name:Harry
Enter Harry’s semester marks: 41 52 68 56 40
Enter student name:Uushona
Enter Uushona’s semester marks: 30 20 52 38 47
Enter student name:Sililo
Enter Sililo’s semester marks: 23 33 45 19 27
Output1:
Student Semester mark Qualifies for Exam?
--------- ------------------- -----------------------
John 66 YES
Harry 50 YES
Uushona 38 NO
Sililo 30 NO
Qualifying mark is 50 and above.
test1
(Weight 20%)
test2
(Weight 20%)
labs
(Weight 20%)
in_class exercise
(Weight 10%)
assignment
(Weight 30%)
John
50
60
79
89
63
Harry
41
52
68
56
40
Uushona
30
20
52
38
47
Sililo
23
33
45
19
27
Explanation / Answer
ScoreQualifier.java
import java.util.Scanner;
public class ScoreQualifier {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter class size: ");
int n = scan.nextInt();
int scores[][]= new int[n][5];
String names[]=new String[n];
for(int i=0;i<scores.length;i++) {
System.out.println("Enter student name: ");
names[i] = scan.next();
System.out.println("Enter "+names[i]+"’s semester marks: ");
for(int j=0;j<scores[i].length;j++) {
scores[i][j] = scan.nextInt();
}
}
System.out.println("Student Semester mark Qualifies for Exam?");
int sum = 0;
for(int i=0;i<scores.length;i++) {
sum=0;
for(int j=0;j<scores[i].length;j++) {
sum+=scores[i][j];
}
int avg = (sum/5);
if(avg>=50) {
System.out.println(names[i]+" "+avg+" YES");
} else {
System.out.println(names[i]+" "+avg+" NO");
}
}
}
}
Output:
Enter class size:
2
Enter student name:
John
Enter John’s semester marks:
50 60 79 89 63
Enter student name:
Harry
Enter Harry’s semester marks:
41 52 68 56 40
Student Semester mark Qualifies for Exam?
John 68 YES
Harry 51 YES
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.