// program to total the values input + count them #include #include int main() { try { int i(0); int total(0); int count(0); int mean(0); std::cout << "TOTALS, COUNT AND MEAN PROGRAM" << '\n'; do{ std::cout << "Type in a number : "; std::cout << "(Zero ends the program)" ; std::cin >> i; if(not std::cin) { std::cout << "The total so far was " << total << '\n'; std:: cout << "The numbers entered so far was " << count << '\n'; std::cout << "The Mean so far was " << mean << '\n'; throw std::exception(); } if (i < 1) break; total += i; ++count; mean = total / count; } while(true); std::cout << "The Total of the values is " << total << '\n'; std::cout << "There were " << count << " numbers entered" << '\n'; std::cout << "The mean of these values is " << mean << '\n'; } catch(...) { std::cerr << "***An exception was thrown.***\n"; } }