Hi, I need help with a program. I am new to programing. I need to read from a file and output to a file. I am able to do that. But I am having trouble when it comes to outputting the average total time (b+c+d). It only does the average of the last number. I want to add all the numbers in total time and average those. Thanks for the help.
This is the input file.
A 31 27 52
B 29 31 58
C 35 36 51
D 34 36 62
This is the output file im getting.
Running Swimming Biking Total Time
A 31 27 52 110
B 29 31 58 118
C 35 36 51 122
D 34 36 62 132
// initial condition
sum = 0
count = 0
// Repeating:
for each element
sum += something about the element
++count
// after N elements the count==N and N values have been added to the sum
// average (unless count==0)
double average = static_cast<double>(sum) / count;