write a java application and use two dimensional array that will store five information technology courses , with the average amount of students registered for each course
public class App {
public static void main(String[] args) {
String[] regNames = { "COURSE", "REGISTRATION 1", "REGISTRATION 2", "REGISTRATION 3" , "TOTAL","DELIVER COURSE" };
String[] courseNames = { "Programming 101", "Web Dev 101", "Databases 101", "Logic 101", "Management 101" };
int[][] scores = { { 50, 10, 50 }, { 10, 50, 20 }, { 10, 10, 20 }, { 10, 7, 5 }, { 30, 10, 50 } };
int[] totalForCourse = { 0, 0, 0 };
int[] totalForStudent = { 0, 0, 0,0,0 };
for (int i = 0; i < regNames.length; i++) {
if (i == 0) {
System.out.printf("%-27s ", regNames[i]);
} else {
System.out.printf("%-28s ", regNames[i]);
}
}
System.out.println();
for (int i = 0; i < scores.length; i++) {
System.out.printf("%-27s ", courseNames[i]);
for (int j = 0; j < scores[i].length; j++) {
System.out.printf("%-28s ", scores[i][j]);
totalForCourse[j]+=scores[i][j];
totalForStudent[i]+=scores[i][j];
}
System.out.printf("%-28s ", totalForStudent[i]);
if(totalForStudent[i]>=70) {
System.out.printf("%-18s ", "Yes");
}else {
System.out.printf("%-18s ", "No");
}
System.out.println();
}
System.out.printf("%-27s ", "TOTAL");
for (int i = 0; i < totalForCourse.length; i++) {
System.out.printf("%-28s ", totalForCourse[i]);
}
}
}
Comments
Leave a comment