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

Create a program that determines grades at the end of the semester. Specificatio

ID: 3845359 • Letter: C

Question

Create a program that determines grades at the end of the semester.

Specifications

Using the array class (Links to an external site.), construct a 5 x 7 two-dimensional array based on the following table

Calculate the average for each student and store it in the Ave column.

Calculate the weighted average for each student (the first grade gets a weight of .2, the second a weight of .3, the third a weight of .3, and the fourth a weight of .2) and store it in the Wt Ave column.

HINT: Use a loop: for each row, calculate the ave and weighted average and store the values in the appropriate column.

Output the contents of the entire array neatly formatted in columns and rows with appropriate row and column labels.

student Grade1 Grade2 grade3 grade4 ave Wt ave 1 85 88 90 81 2 73 68 75 77 3 94 89 82 91 4 88 79 81 84 5 71 65 78 73

Explanation / Answer

Hi buddy, Please find the below java program

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
  
   public static void main (String[] args) throws java.lang.Exception
   {
       //Initializing the 2d array with the given data. Avg and Wt Avg are initialized with 0
       double t[][] = new double[5][];
       t[0] = new double[]{1,85,88,90,81,0,0};
       t[1] = new double[]{2,73,68,75,77,0,0};
       t[2] = new double[]{3,94,89,82,91,0,0};
       t[3] = new double[]{4,88,79,81,84,0,0};
       t[4] = new double[]{5,71,65,78,73,0,0};
      
       //Constants for finding weighted averages
       double w[] = new double[]{0,0.2,0.3,0.3,0.2};
      
       //This block finds the average
       for(int i=0;i<5;i++){
       for(int j=1;j<=4;j++){
       t[i][5] = t[i][5] + t[i][j];
       }
       t[i][5] = t[i][5]/4d;
       }
      
       //This block finds the weighted average
       for(int i=0;i<5;i++){
       for(int j=1;j<=4;j++){
       t[i][6] = t[i][6] + w[j]*t[i][j];
       }
       t[i][6] = t[i][6]/4d;
       }
      
       //This block prints the data
       System.out.println("Student Grade1 Grade2 Grade3 Grade4 Ave WtAve");
       for(int i=0;i<5;i++){
       for(int j=0;j<5;j++){
       System.out.print((int)t[i][j]+" ");
       }
       for(int j=5;j<7;j++){
       System.out.print(t[i][j]+" ");
       }
       System.out.println();
       }
      
      
   }
}

OUTPUT :

Student Grade1 Grade2 Grade3 Grade4 Ave WtAve
1 85 88 90 81 86.0 21.650000000000002
2 73 68 75 77 73.25 18.225
3 94 89 82 91 89.0 22.075
4 88 79 81 84 83.0 20.599999999999998
5 71 65 78 73 71.75 17.925

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