Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to create a CourseGrades application that simulates a grade book for a cl

ID: 3546634 • Letter: I

Question

I need to create a CourseGrades application that simulates a grade book for a class with five students that each has 5 test scores. The CourseGrades application should use a GradeBookclass that has a member variables grades, which is a two-dimensional array of integers, and methodsgetGrades() for prompting the user for the test grades for each student, showGrades() that displays the grades for the class, studentAvg() that has a student number parameter and then returns the average grade for that student, testAvg() that has a test number parameter and then returns the average grade for that test.

Explanation / Answer

import java.util.Scanner;

class GradeBook{
    int grades[][];
    public GradeBook() {
        grades=new int[5][5];
    }
   
    void getGrades(){
        Scanner in =new Scanner(System.in);
        for(int i=0;i<5;i++){
            System.out.println("Enter grades for student"+(i+1));
            for(int j=0;j<5;j++){
                System.out.print("Enter "+(j+1)+" score=");
                grades[i][j]=in.nextInt();
            }
        }
       
    }
   
    void showGrades(){
        for(int i=0;i<5;i++){
            System.out.println(" Grades for student"+(i+1));
            for(int j=0;j<5;j++){
                System.out.println("Grades in "+j+"score = "+grades[i][j]);
            }
        }
    }
    float studentAvg(int i){
        int sum=0;
        for(int j :grades[i]){
            sum+=j;
        }
        return sum/5;
    }
   
    float testAvg(int i){
        int sum=0;
        for(int j=0;j<5;j++){
            sum+=grades[j][i];
        }
        return (float)sum/5;
    }
}

public class CourseGrades {

    public static void main(String[] args) {
        GradeBook book = new GradeBook();
        book.getGrades();
        book.showGrades();
        System.out.println(" Average grade of student 1 is"+book.studentAvg(0));
        System.out.println(" Average grade of test 1 is"+book.testAvg(0));
       

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote