Question: Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits)(I NEED JAVA CODE).
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
output should be like this
Please enter the file name or type QUIT to exit: Total: 11.800 Average: 2.950
Please enter the file name or type QUIT to exit: Total: 17.300 Average: 3.460
Please enter the file name or type QUIT to exit: Total: 1.124 Average: 1.124
Please enter the file name or type QUIT to exit: File input4.txt is empty.
Please enter the file name or type QUIT to exit: File: input5.txt does not exist. Please enter the file name again or type QUIT to exit: Total: 11.800 Average: 2.950
Please enter the file name or type QUIT to exit:
Please enter the file name or type QUIT to exit: File: input5.txt does not exist. Please enter the file name again or type QUIT to exit:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
