Question
Using Java, Write a program to calculate the average test scores of each student and the class average. All these data are stored in a
Using Java, Write a program to calculate the average test scores of each student and the class average. All these data are stored in a file (file name would be data.txt). The 1st number in the file is number of students (N), the 2nd number in the file is number of test for each student (M), the rest of N X M numbers are test scores.
The program MUST have the following two methods, in additional to the main method:
public static double[] studentAvg (double[ ][ ] ) //input to the method is the N by M 2D array //output is 1D array of student's average
public static double classAvg (double[ ] ) //input to the method is the 1D array of student's average //output is the class average
You also need to use Scanner, FileInputStream, and IOException classes.
(1) Prompting the user to enter a file, then input all the test scores in the file into a 2D array and the output them
(2) Invoke studentAvg to calculate the average of each student
(3) Invoke classAvg to calculate the average of the class
14.8 Prog8 Read From a File (find avg) Write a program to calculate the average test scores of each student and the class average. All these data are stored in a file (file name would be data.txt). The 1st number in the file is number of students (N), the 2nd number in the file is number of test for each student (M). the rest of N X M numbers are test scores. Here is an example of the content in a data file (2 students and 3 test scores) 2 3 85.5 72 64.5 60.5 88 90 Here is an example of output Enter the file name: The data in the file are 85.5 72 64.5 60.5 88 90 There are 2 students The averages for each student are 74.00 79.50 The class average is 76.75 The program MUST have the following two methods, in additional to the main method (3 points): A method named studentAvg that calculates each student's average, the header of the method should be
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started