//Accumulator2.cpp // tom bailey 25 sep 06 // Request n. // Print the sum of the integers from 1 to n. // Print the sum of the (sum of the integers from 1 to k) // for all k from 1 to n. // Use objects of the accumulator class Summer to track the // two sums. #include using std::cin; using std::cout; using std::endl; #include "MyAccumulators1.h" int main() { Summer sum; Summer sumOfSums; cout << "Enter last integer in sums: "; int n; cin >> n; for( int i=1; i<=n; ++i ) { sum.append( i ); sumOfSums.append( sum() ); } cout << n << endl; cout << sum() << endl; cout << sumOfSums() << endl; return 0; }