SOURCE FILE: activity.cpp
//******************************************************************
// Activity program
// This program outputs an appropriate activity
// for a given temperature
//******************************************************************
#include <iostream>
using namespace std;
void GetTemp( int& ); // Function prototypes
void PrintActivity( int );
int main()
{
int temperature; // The outside temperature
GetTemp(temperature); // Function call
PrintActivity(temperature); // Function call
return 0;
}
//******************************************************************
void GetTemp( int& temp ) // Reference parameter
// This function prompts for a temperature to be entered,
// reads the input value into temp, and echo-prints it
{
cout << "Enter the outside temperature:" << endl;
cin >> temp;
cout << "The current temperature is " << temp << endl;
}
//******************************************************************
void PrintActivity( int temp ) // Value parameter
// Given the value of temp, this function prints a message
// indicating an appropriate activity
{
cout << "The recommended activity is ";
if (temp > 85)
cout << "swimming." << endl;
else if (temp > 70)
cout << "tennis." << endl;
else if (temp > 32)
cout << "golf." << endl;
else if (temp > 0)
cout << "skiing." << endl;
else
cout << "dancing." << endl;
}