Question: Goal: Processing data read from multiple files Assignment: You have stored your yearly revenue in multiple files, each representing a different month. For example, January's
Goal: Processing data read from multiple files
Assignment: You have stored your yearly revenue in multiple files, each representing a different month. For example, January's data is in january.txt February's data is in february.txt and so on Each file contains a single number representing the revenue for that month. However, some files may be missing or contain no data.
Write a code snippet that allows the user to enter filenames through the console. Your program should calculate the average revenue by reading each file, only counting months where the file opens successfully and contains a value. If a file can't be opened or has no data, it should be skipped. The user should type "stop" when there are no more files to check. Display the average revenue on the console. If no valid data is found in any files, print to the console.
Note: Assume the fstream and iostream header files have been included.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
