191k views
3 votes
) For a course with n students, an n X 3 array, int[][] arr, holds scores on 3 exams. Each row holds the exam scores for one student, one exam per column. Write code to get the average of cumulative exam score, over all students. For instance, if student1 scored 50,60,65 in the three exams, and student2 scored 75,85,90, then the cumulative exam score for student1 is 175 and that for student2 is 250, and the resulting average is 212.5

2 Answers

4 votes

Answer:

3.14159265358979323846264338327950288419716939937510 582097494459230781640628620899 86280348253421170679

Step-by-step explanation:

User Logan Wlv
by
5.0k points
5 votes

Answer:

Following are the code to this question:

import java.util.*;//import package

public class Main //defining a class

{

public static void main(String[] ax)//defining main method

{

int student[][] = {{50,60,65},{75,85,90}}; //defining double array student

int Row=0,Col=0;//defining integer variable

double x;//defining double variable

for (int a = 0; a <student.length; a++)//use for loop to holding row value

{

for (int b = 0; b<student[a].length; b++)//use for loop to holding column value

{

Row += student[a][b];//add row value

Col += student[0][b];//add column value

}

}

System.out.println(x=Row/2);//dividing value and calculating average value

}

}

Output:

212.0

Step-by-step explanation:

In the above code, a 2D array student is declared, that holds some value in the next step, two integer variable "Row and Col", is declared, which it uses the for loop to add value in "Row and Col", and in the next step, a double variable x is declared, that add value and calculates its average value and store its value in x variable and print its value.

User Prashanta
by
5.8k points