Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
18.1k views
in Computer by (48.9k points)
reopened by

The annual examination results of 50 students in a class is tabulated as follows :

Write a program to read the data, calculate and display the following : 

(a) Average marks obtained by each student. 

(b) Print the roll number and average marks of the students whose average mark is above 80. 

(c) Print the roll number and average marks of the students whose average mark is below 40.

Please log in or register to answer this question.

1 Answer

+1 vote
by (49.9k points)

import java. io.*;

by (128 points)
import java.util.Scanner;

public class ExamResult
{
    public static void main(String args[]) {
        final int TOTAL_STUDENTS = 50;
        Scanner in = new Scanner(System.in);
        
        int rollNo[] = new int[TOTAL_STUDENTS];
        int sA[] = new int[TOTAL_STUDENTS];
        int sB[] = new int[TOTAL_STUDENTS];
        int sC[] = new int[TOTAL_STUDENTS];
        double avg[] = new double[TOTAL_STUDENTS];
        
        for (int i = 0; i < TOTAL_STUDENTS; i++) {
            System.out.println("Enter student " + (i+1) + " details:");
            System.out.print("Roll No: ");
            rollNo[i] = in.nextInt();
            System.out.print("Subject A Marks: ");
            sA[i] = in.nextInt();
            System.out.print("Subject B Marks: ");
            sB[i] = in.nextInt();
            System.out.print("Subject C Marks: ");
            sC[i] = in.nextInt();
            avg[i] = (sA[i] + sB[i] + sC[i]) / 3.0;
        }
        
        System.out.println("\nRoll No\tAverage Marks");
        for (int i = 0; i < TOTAL_STUDENTS; i++) {
            System.out.println(rollNo[i] + "\t" + avg[i]);
        }
        
        System.out.println("\nStudents with Average above 80:");
        for (int i = 0; i < TOTAL_STUDENTS; i++) {
            if (avg[i] > 80)
                System.out.println(rollNo[i] + "\t" + avg[i]);
        }
        
        System.out.println("\nStudents with Average below 40:");
        for (int i = 0; i < TOTAL_STUDENTS; i++) {
            if (avg[i] < 40)
                System.out.println(rollNo[i] + "\t" + avg[i]);
        }
    }
}


Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...