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 03:50
You are working as a security analyst in a company xyz that owns the whole subnet range of 23.0.0.0/8 and 192.168.0.0/8. while monitoring the data, you find a high number of outbound connections. you see that ip's owned by xyz (internal) and private ip's are communicating to a single public ip. therefore, the internal ip's are sending data to the public ip. after further analysis, you find out that this public ip is a blacklisted ip, and the internal communicating devices are compromised. what kind of attack does the above scenario depict?
Answers: 3
question
Computers and Technology, 22.06.2019 14:30
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
question
Computers and Technology, 23.06.2019 20:40
Instruction active describing list features which statements accurately describe the features of word that are used to create lists? check all that apply. the tab key can be used to create a sublist. the enter key can be used to add an item to a list. the numbering feature allows for the use of letters in a list. the numbering feature can change the numbers to bullets in a list. the multilevel list feature provides options for different levels in a list.
Answers: 2
question
Computers and Technology, 24.06.2019 20:00
Avirus enters a computer or network as code embedded in other software directly from another computer
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