#include #include // This program computes the mean of a set of numbers that the user inputs. // THe program keeps asking the user for numbers as long as the number // is greater than or equal to zero. A negative number means the list // has ended. int main() { double x; // current value double total; // sum of the values double count; // number of values entered total = 0; // initialization count = 0; do { cout << "Enter a number: "; cin >> x; if (x >= 0) { total += x; count++; } } while (x >= 0); cout << "The total is " << total << endl; if (count > 0) { cout << "The mean is " << total/count << endl; } else { cout << "Cannot compute the mean" << endl; } }