Answer to Question #256724 in Java | JSP | JSF for Amadix

Question #256724

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).


1
Expert's answer
2021-10-26T06:39:34-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter class size: ");
        int size = in.nextInt();
        String[] names = new String[size];
        int[][] marks = new int[size][5];
        for (int i = 0; i < names.length; i++) {
            System.out.print("Name: ");
            names[i] = in.next();
            for (int j = 0; j < marks[i].length; j++) {
                System.out.print("Mark " + (j + 1) + ": ");
                marks[i][j] = in.nextInt();
            }
        }
        System.out.println("\nPRG510S");
        System.out.printf("%-12s%-20s%-20s%-20s%-20s%-20s%-10s\n", "name", "test1", "test2", "labs",
                "in_class exercises", "assignment", "total");
        System.out.printf("%-12s%-20s%-20s%-20s%-20s%-20s\n", "", "(Weight 20%)", "(Weight 20%)", "(Weight 20%)",
                "(Weight 10%)", "(Weight 30%)");
        int total;
        int[] weights = {20, 20, 20, 10, 30};
        for (int i = 0; i < names.length; i++) {
            System.out.printf("%-12s", names[i]);
            total = 0;
            for (int j = 0; j < marks[i].length; j++) {
                System.out.printf("%-20s", marks[i][j]);
                total += marks[i][j] * weights[j];
            }
            System.out.printf("%-10s\n", 0.01 * total);
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS