#include<iostream>
using namespace std;
int main()
{
// Initialize month, temperature, and season variables
int month; // number for month
float inputTemperature, tooCold, tooHot;
string season; // name of season
// Identify hot and cold temperatures for different seasons
const float coldSummer = 75, hotSummer = 105;
const float coldFall = 50, hotFall = 80;
const float coldWinter = 15, hotWinter = 60;
const float coldSpring = 50, hotSpring = 80;
// Initialize variable about whether to compare
// user-input temperature to standard temperatures
// for the season --- if the specified month is
// invalid ( month < 1 or month > 12),
// compareTemperature will be false
bool compareTemperature = true;
// Get month from user
cout << "Enter month (1 for January, 2 for February, etc): ";
cin >> month;
// Get temperature from user
cout << "Enter temperature: ";
cin >> inputTemperature;
// Set cold and hot limits based on season
switch ( month ) {
case 1 : // For winter months
case 2 :
case 3 :
tooCold = coldWinter; tooHot = hotWinter;
season = "winter";
break;
case 4 : // For spring months
case 5 :
case 6 :
tooCold = coldSpring; tooHot = hotSpring;
season = "spring";
break;
case 7 : // For summer months
case 8 :
case 9 :
tooCold = coldSummer; tooHot = hotSummer;
season = "summer";
break;
case 10 : // For fall months
case 11 :
case 12 :
tooCold = coldFall; tooHot = hotFall;
season = "fall";
break;
default : // Say if number is not a proper month
// (optional!)
cout << "Invalid number for a month\n";
compareTemperature = false;
break;
}
// If entered month is valid and temperature is too
// hot or cold for the season, output a statement
// saying so
if ( compareTemperature) { // curly braces not technically needed
if ( inputTemperature < tooCold )
cout << "It is too cold for " << season << "!\n";
else if (inputTemperature > tooHot )
cout << "It is too hot for " << season << "!\n";
}
return 0;
}