Answer to Question #236097 in Java | JSP | JSF for mack

Question #236097


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


Student name JD521 PRG521 IPG521

Maxwell 80 65 70

Carl 95 70 65

Gerhard 87 80 73

Paul 65 45 60

James 45 87 65



1
Expert's answer
2021-09-12T02:58:24-0400
import java.util.Scanner;


public class Main {


	/***
	 * main
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		// a two-dimensional array of type double to contain the three different SD
		// Marks
		double[][] marks = { { 80, 65, 70 }, { 95, 70, 65 }, { 87, 80, 73 }, { 65, 45, 60 }, { 45, 87, 65 },
				{ 48, 96, 36 } };
		String[] studentNames = { "Maxwell", "Carl", "Gerhard", "Paul", "James", "Cena" };
		int position = 1;
		while (position >= 0 && position < 6) {
			System.out.print("Enter the student position (1 - 6)(To stop enter a number greater than 6): ");
			position = in.nextInt();
			position--;
			if (position >= 0 && position < 6) {
				double max = 0;
				for (int j = 0; j < 3; j++) {
					if (marks[position][j] > max) {
						max = marks[position][j];
					}
				}
				System.out.printf("Student name: %s\n", studentNames[position]);
				System.out.printf("Mark 1: %.0f\n", marks[position][0]);
				System.out.printf("Mark 2: %.0f\n", marks[position][1]);
				System.out.printf("Mark 3: %.0f\n", marks[position][2]);
				System.out.printf("Max mark: %.0f\n", max);
			}


		}
		System.out.printf("%-15s%-15s%-15s%-15s%-15s%-15s%-15s\n", "Name", "JD521", "PRG521", "IP521", "Max", "Average",
				"Pass/Fail");
		for (int i = 0; i < 6; i++) {
			double totalMarks = 0;
			double max = 0;
			for (int j = 0; j < 3; j++) {
				totalMarks += marks[i][j];
				if (marks[i][j] > max) {
					max = marks[i][j];
				}
			}
			double average = totalMarks / 3.0;
			String passFail = "Fail";
			if (average >= 70) {
				passFail = "Pass";
			}
			System.out.printf("%-15s%-15.0f%-15.0f%-15.0f%-15.0f%-15.0f%-15s\n", studentNames[i], marks[i][0],
					marks[i][1], marks[i][2], max, average, passFail);
		}
		in.close();
	}
}





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