Answer to Question #235685 in Java | JSP | JSF for Siya

Question #235685

Create a two-dimensional array of type double to contain the three different SD Marks (JD521, PRG521, and IP521) for six different students. A single array of type String must be used to store the student names (Maxwell, Carl, Gerhard, Paul, James, and Cena).

Allow a user to enter in a number, ranging from 1 to 6, which will represent the student position in the table MCSD max and present the marks for each respecting module. The program can only stop when the user enter a number greater than 6.

Printout the student name including the JD521, PRG521, and IP521 max, the total of marks and the average of all marks. Use a condition statement to decide that the student has passed or not (Pass rate is 70).


1
Expert's answer
2021-09-10T09:03:59-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] subjects = {"JD521", "PRG521", "IP521"};
        double[][] marks = new double[3][6];
        String[] studentNames = {"Maxwell", "Carl", "Gerhard", "Paul", "James", "Cena"};
        int studentNumber;
        double total;
        while (true) {
            System.out.println("Enter student number(1 - 6)( >6 to stop):");
            studentNumber = in.nextInt();
            if (studentNumber > 6) {
                break;
            }
            for (int i = 0; i < subjects.length; i++) {
                System.out.println("Enter mark for " + subjects[i] + ": ");
                marks[i][studentNumber - 1] = in.nextDouble();
            }
        }
        System.out.print("Name ");
        for (String subject : subjects) {
            System.out.print(subject + " ");
        }
        System.out.println("Total Average Pass");
        for (int i = 0; i < studentNames.length; i++) {
            total = 0;
            System.out.print(studentNames[i] + " ");
            for (double[] mark : marks) {
                System.out.print(mark[i] + " ");
                total += mark[i];
            }
            System.out.printf("%.2f %.2f %s\n", total, (total / 3), (total / 3) >= 70);
        }
    }
}

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