The objective of this lab is to help you better understand how to do file I/O with C++.
After completing this lab, you should be able to read data from a file, and use the state bits in the stream classes to know if a read operation was successful.
You should also be able to read until you find the end of the file.
For this assignment you will write a program works as follows:
Your program declares an array of double values. You will use this array to hold voltages. The array should hold up to 100 voltage values.
Your program should then open a file containing a set of voltage values. You can use the sample file below. Name the file “voltages.txt”.
Your program should work for any number of values in the file, up to 100. Your program should verify that the file opened successfully.
Assume that the file is in the same folder as your executable.
Your program will now read the voltage values from the file and store them in the array. Test the state of the stream after each read operation to make sure that it worked.
Keep reading until you reach the end of the file.
Calculate the average voltage value and display it.
You can find a sample file to test your program here. If you create your own file to test this program with, it must have a blank line at the end.
After you are satisfied that your program works correctly, place the following files into a zip folder and submit it to Canvas as Lab #5.
o All source code files contain a complete file prologue
o Source code files contain declaration that you did not copy code
o Project has been properly submitted to Canvas
o Code meets style guidelines
o The program works correctly.