A Math teacher is teaching Math course to a set of classes (each class may have different number of students) and want to check the behavior of his students in a homework report. The teacher gave the classes the same exam and marked their answer and wants to know the class whose students got the highest average.
Help the teacher in the required analysis of student’s marks by implementing a Java program ClassAverageMArks2DimmArray using 2-dimensional array to store the students marks and then compute the average of each class student’s marks. The program has the following specification:
• A Method titled averageClassMarks for computing the average (as double) of a class students marks (given to the method as a single-dimensional array)
• Another Method titled averageAliclassesMarks for computing the average (as single array of double) of all the classes class student’s marks (given to the method as a 2- dimensional array). This method has to repeatedly call the first method averageClassMarks to calculate the average of student’s marks in each class.
• The program reads from the user the number of classes and then reads the classes student’s marks (as integer values) line by line. Each line has the number of students in the class then the student’s marks.
• The program calls method averageAliclassesMarks to calculate all the average values of marks of all the classes. Again, method averageAliclassesMarks has to repeatedly call the first method averageClassMarks.
• Finally, the program then prints all the average values (rounded to 2 decimal points) of all classes student’s marks and the highest average mark as well.
• The program has to work EXACTLY as given in the following sample run. Sample Run:
Enter number of classes: 5
Enter student’s marks of all the classes line by line such that, each line contains first the number of students in a class followed by the student’s marks:
6 50 84 76 94 62 98
5 42 64 97 88 80
6 25 35 86 47 36 75
7 59 74 96 94 82 75 98
4 88 62 56 74
Classes average marks:
The highest average is 82.57 and it is for class 4.
public class Main
public static double averageClassMarks(int arr)
public static void averageAllClassesMarks(int arr)
System.out.println(“\nClasses average marks:”);
System.out.println(“\nThe highest average is “+String.format(“%.2f”,highest_average)+” and it is for class “+highest_class);
public static void main(String args)
Scanner sc=new Scanner(System.in);
System.out.print(“\nEnter number of classes: “);
System.out.println(“\nEnter student’s marks of all the classes line by line such that, each line contains first the number of students in a class followed by the student’s marks:\n”);
int arr=new int[n];