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°, you schedule swimming. If the temperature is above 70° and less than or equal to 85°, you schedule baseball. If the temperature is above 32° and less than or equal to 70°, you schedule basketball. Finally, if the temperature is below 32°,you send everyone home.
Create a C++ program that takes temperature as input and provides as output your sports decision. Assume that temperatures are only expressed as integers. In the program, include 2 void functions titled getTemp and printActivity, each with an int argument.
- The function getTemp should have a Reference parameter that gets the temperature in getTemp and then passes the value back to be printed in main( ), and
- printActivity should have a Value parameter.
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 on the screen. Be careful and note that this problem requires you to input the temperature into getTemp and not directly into the main function.© BrainMass Inc. brainmass.com October 17, 2018, 12:08 pm ad1c9bdddf
Please note that the given question does not specify any action when temperature is 32 degree Fahrenheit. Attached program (566646.cpp) captures this fact by indicating that no action was specified for this temperature value. You should edit it out in case you do not want it.
A simple edit would be ...
The solution sticks to the specification and explains in brief where mistake could creep in when addressing this question. It also provides an equivalent nested-if implementation of printActivity function for better understanding of printActivity function.