// // Course: CS311 Data ... // // File: avg.cpp // Author: John Wang // Instructor: Dr. Wang // // Due: Wed. Sept. .. // // Goal: Read each line of data, out their avg // as well as avg for all lines // #include using namespace std; int main() { int var1, var2; // hold two data float line_avg; float sum = 0.0; // sum up avgs for all lines int num_line = 0; cin >> var1 >> var2; // first line while(cin) // EOF-ctrl loop { // processing here line_avg = (var1 + var2) / 2.0; cout << var1 << "\t" << var2 << "\t" << "AVG: " << line_avg << endl; sum += line_avg; num_line ++; cin >> var1 >> var2; // read the next line } cout << "Total number of lines: " << num_line << endl; cout << "Total avg: " << sum << endl; return 0; }