//Accumulator3.cpp // tom bailey 25 sep 06 // Request n. // Print the sum of the integers from 1 to n. // Print the mean of (the sum of the integers from 1 to k) // for all k from 1 to n. // Use objects of the accumulator classes Summer and // Averager to track the sum and average properties of // the sequences. #include using std::cin; using std::cout; using std::endl; #include "MyAccumulators2.h" int main() { Summer sum; Averager average; cout << "Enter last integer in sequence: "; int n; cin >> n; for( int i=1; i<=n; ++i ) { sum.append( i ); average.append( sum() ); } cout << "The sequence is 1 ... " << n << endl; cout << "Its sum is " << sum() << endl; cout << "The mean of all the partial sums is " << average() << endl; return 0; }