< previous page page_218 next page >

Page 218
int main()
{
    int temperature;    // The outside temperature

                        // Get temperature

    cout << Enter the outside temperature:<< endl;
    cin >> temperature
    cout << The current temperature is  < temperature <.
         << endl;
                        // Print activity

    cout << The recommended activity is ;
    if (temperature > 85)
        cout << swimming. << endl;
    else if (temperature > 70)
        cout << tennis. << endl;
    else if (temperature > 32)
        cout << golf. << endl;
    else if (temperature > 0)
        cout << skiing. << endl;
    else
        cout << dancing. << endl;

    return 0;
}
Here are two sample runs of the Activity program. The user's input is in color.
Enter the outside temperature:
-20
The current temperature is -20.
The recommended activity is dancing.

Enter the outside temperature:

52
The current temperature is 52.
The recommended activity is golf.
Figure 5-6 shows how the flow of control works in module Print Activity.

 
< previous page page_218 next page >