Question: Write a complete C++ program called Lab8C. cpp that calculates the running sum and average of the numbers stored in a text file. Download the

 Write a complete C++ program called Lab8C. cpp that calculates the

Write a complete C++ program called Lab8C. cpp that calculates the running sum and average of the numbers stored in a text file. Download the data file "numbers.dat" from Blackboard. Read numbers from this file, one number at the time, calculate the sum of the numbers you have read and divide by the count of numbers you have read to calculate running sum and average. You'll have an updated sum and average for every number you read. Write sum and average values a new data file "results.dat" AFTER EVERY UPDATE. The format in the output file must be: Sum = XXXX Average = XXXX Sum = XXXX Average = XXXX Sum = XXXX Average = XXXX where XXXX above must be replaced by the values you calculated. For example, after you read the third number, your sum variable will have the sum of the first three numbers and the average variable will have the average of the three numbers. You will write these values in the output file. Then, when you read the fourth number, the sum variable should update to the sum of the four numbers and the average variable should update to the average of the four numbers. Then, you will write these values in the output file and so on. This can all be done in main, but remember to include the three steps (i.e., open file, process file, and close file) when working with files as well as to error check the opening of the file. Before writing the code, you may want to write out the algorithm, or steps, on paper of how you propose to solve this problem. Note that you will submit this file to Blackboard

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!