Question: 8.6 Program 8: Input from a file The program is to read a set of integers from a file (file name such as data.txt); the

 8.6 Program 8: Input from a file The program is toread a set of integers from a file (file name such as

8.6 Program 8: Input from a file The program is to read a set of integers from a file (file name such as data.txt); the program then calculates the sums and the averages of the integers You need to use Scanner, FilelnputStream, IOException, and ArrayList classes. You MUST use at least two methods with the following headings: public static int sum (ArrayList array) //calculate sum of the integers public static double average (ArrayList array, int total) //calculate average of the integers You should use hasNext0 method in the Scanner class to control the loop for reading integers from the file (1) Prompting the user to enter a file, then input all the integers in the file into array and the output them (2 points) Ex Enter the file name> The data in the file is 10 14-45 30 -50 19 0 88 2) Complete the sum (ArrayList a) and average (ArrayList a, int total) (4 points) (3) In main0.call the both sum and average methods, then output the results.(4 points) Ex Enter the file name> The data in the file is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!