Answer to Question #315823 in Java | JSP | JSF for Geeee

Question #315823

Write the pseudocode for the following scenario. The final exam marks for 10 students



are 65, 45, 78, 65, 89, 65, 79, 67, 75, and 63. The marks are stored in an array. Find:



• The student with the highest mark.



• The student with the lowest mark.



• The total marks for all the students.



• The overall average.

1
Expert's answer
2022-03-22T09:07:19-0400
public class Main {
    public static void main(String[] args) {
        int[] marks = {65, 45, 78, 65, 89, 65, 79, 67, 75, 63};

        int maxMark = 0, minMark = marks[0], sumMarks = 0;
        double middleMark;

        for (int a:marks) {
            if(maxMark < a){
                maxMark = a;
            }
            if(minMark > a){
                minMark = a;
            }
            sumMarks += a;
        }

        middleMark = (double) sumMarks / 2;

        System.out.print(   "The student with the highest mark: " + maxMark +
                            "\nThe student with the lowest mark: " + minMark +
                            "\nThe total marks for all the students: " + sumMarks +
                            "\nThe overall average: " + middleMark);
    }
}

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