This code will show the data from the .txt file "file1" the data is (0.0 0.1 0.2 0.5 0.8 0.9 1.0)
What I'm trying to do is take these float values and add them all up and divide them by 7 (finding the average and output that)
Convert it into a percent and print it in a field:
Width of 6 with 2 digits after the decimal point...
I tried doing something like cout << "the average is: " << data/7 << endl; but that didn't work. I got an error that said "/" was not an operator.
with cout << "the average is: " << data/7 << endl;
your trying to divide a string by 7.
The following assumes all of the values are on the same line in the file.
I skipped reading in from a file since you already have that.
Use getline with space as the delimiter and convert each value into a float and add to the total.