Please send questions to st10@humboldt.edu .
/*-----
  Contract: main: void -> int

  Purpose: interactively asks user for temperatures until he/she
           enters he/she is ready to stop by entering a sentinel-value --
           a non-data value -- greater than MAX_TEMP to stop, and
           then prints to the screen the number and average of
           the temperatures given
  
  Examples: if, when prompted, the user enters:
201
...then this program should print to the screen:
no temperatures were given
-----------
           if, when prompted, the user enters:
78.5, 20, -10, 100.6, 200.1
...then this program should print to the screen:
the average temperature of these 4 temperatures is: 47.275

  by: Sharon Tuttle
  last modified: 04-18-10
-----*/

#include <iostream>
using namespace std;

int main()
{
    // set up the local variables and constants needed 

    const double MAX_TEMP = 200.0;
    double curr_temp;
    double sum_temps = 0.0;
    int num_temps = 0;

    // get the temperatures from the user and sum them

    cout << "enter first temperature " << endl;
    cout << " (or a temp greater than " 
         << MAX_TEMP << " to stop): ";
    cin >> curr_temp;

    while (curr_temp <= MAX_TEMP)
    {
        num_temps++;
        sum_temps += curr_temp;
    
        cout << "enter next temperature " << endl;
        cout << " (or a temp greater than "
             << MAX_TEMP << " to stop): ";
        cin >> curr_temp;
    }

    if (num_temps == 0)
        cout << "no temperatures were given" << endl;
    else
        cout << "the average temperature of these " << num_temps
             << " temperatures is: " << (sum_temps / num_temps) << endl;

    return EXIT_SUCCESS;
}