Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are running a camp and must decide what activities to schedule. You decide t

ID: 3660906 • Letter: Y

Question

You are running a camp and must decide what activities to schedule. You decide to base the decision on the temperature measured in degrees Fahrenheit. If the temperature is above 85 degrees, you schedule swimming. If the temperature is above 70 and less or equal to 85, you schedule baseball. If the temperature is above 32 degrees and less or equal than 70, you schedule basketball. Finally, if the temperature is below 32 degrees, you send everyone home. Create a program that takes the temperatures as input and provides as output your sports decision. Temperatures expressed as integers. In the program include 2 void functions titled getTemp and printActivity, each with an int argument. The function getTemp should prompt the user for the temperature in Fahrenheit, get the input from the user and return to main() where it prints the temperature on the screen. The function printActivity should determine the activity and print it as output. Input the temperature into getTemp and not directly into the main function.

Explanation / Answer

#include <iostream>
using namespace std;

void printActivity(int temp)
{
     cout << "Activity scheduled: ";
     if(temp > 85)
         cout << "Swimming" << endl;
     else if(temp <= 85 && temp > 70)
         cout << "Baseball" << endl;
     else if(temp <= 70 && temp > 32)
         cout << "Basketball" << endl;
     else
         cout << "Weather too cold. Send everyone home." << endl;
}

void getTemp(int &temp)
{
     cout << "Scheduling The Activity For The Day " << endl;
     cout << "Please input tempurature in Fahrenheit: ";
     cin >> temp;
}

int main()
{
    int temperature;
    getTemp(temperature);
    printActivity(temperature);
    system("pause"); //only works on certain OS (remove)
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote