Question: Write a program in C++ that first prompts the user for the name of a file. The program then opens the file. The program should
Write a program in C++ that first prompts the user for the name of a file. The program then opens the file. The program should read floating point numbers from the file, keeping track of the information required to display a count of the numbers in the file, the product of the numbers in the file, the maximum number in the file, and the average of the numbers in the file. If unexpected characters are found in the file (e.g., alphabetic characters), the program should perform no more processing on the contents of the file but should output the count, product, maximum, and average of the values read until that point. At the end of the program, you should print out the count of numbers read from the file, the product of the numbers read from the file, the maximum number read from the file, and the average of the numbers read from the file. If no numbers were found in the file, you cannot calculate the product, maximum, or average and should indicate that fact. Your program should validate all input and perform error checking as the program is executing.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
