subject

Write a program that asks the user to enter the name of an input file. The program should read all the numbers from the given file and display the count, total, and average of all numbers in the following format (use three decimal digits for total and average):

Count: n

Total: .nnn

Average: .nnn

Requirements: You should assume that the file contains floating point numbers. Total and average should be properly formatted to display three decimal digits. If the file is empty, do not attempt to calculate the total and average, just display a message and exit the program. If the file does not exist, then display a message and allow the user to enter a new name.

View required output

Test Case 1

Standard Input Files in the same directory
double_input1.txt
double_input1.txt

double_input2.txt

double_input3.txt

Please enter the file name or type QUIT to exit:\n
Count: 100\n
Total: -5,748.583\n
Average: -57.486\n
Test Case 2

Standard Input Files in the same directory
double_input2.txt
double_input1.txt

double_input2.txt

double_input3.txt

Please enter the file name or type QUIT to exit:\n
Count: 2000\n
Total: 112,546.485\n
Average: 56.273\n
Test Case 3

Standard Input Files in the same directory
double_input4.txtENTER
double_input1.txt
double_input1.txt

double_input2.txt

double_input3.txt

Please enter the file name or type QUIT to exit:\n
File: double_input4.txt does not exist.\n
Please enter the file name again or type QUIT to exit:\n
Count: 100\n
Total: -5,748.583\n
Average: -57.486\n
Test Case 4

Standard Input Files in the same directory
double_input3.txt
double_input1.txt

double_input2.txt

double_input3.txt

Please enter the file name or type QUIT to exit:\n
File double_input3.txt is empty.\n

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:00
What is the first step in creating a maintenance ?
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
Which of these options are the correct sequence of actions for content to be copied and pasted? select content, click the copy button, click the paste button, and move the insertion point to where the content needs to be inserted. click the copy button, select the content, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, click the copy button, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, move the insertion point to where the content needs to be inserted, click the copy button, and click the paste button.
Answers: 3
question
Computers and Technology, 22.06.2019 22:40
When you type the pwd command, you notice that your current location on the linux filesystem is the /usr/local directory. answer the following questions, assuming that your current directory is /usr/local for each question. a. which command could you use to change to the /usr directory using an absolute pathname? b. which command could you use to change to the /usr directory using a relative pathname? c. which command could you use to change to the /usr/local/share/info directory using an absolute pathname? d. which command could you use to change to the /usr/local/share/info directory using a relative pathname? e. which command could you use to change to the /etc directory using an absolute pathname? f. which command could you use to change to the /etc directory using a relative pathname?
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
Plz ( which is an example of a good url?
Answers: 1
You know the right answer?
Write a program that asks the user to enter the name of an input file. The program should read all t...
Questions
question
Mathematics, 25.01.2021 19:20
question
Biology, 25.01.2021 19:30
question
English, 25.01.2021 19:30
Questions on the website: 13722361