Final answer:
The squirrels play when the temperature is between 60 and 90 unless it's summer when they play up to 100. Using if-else logic, squirrelPlay(70, false) returns true, squirrelPlay(95, false) returns false, and squirrelPlay(95, true) returns true.
Step-by-step explanation:
The student's question involves determining whether squirrels play based on the current temperature and a given condition about the season (summer or not). To solve this, we consider the two scenarios presented: one for summer with an upper temperature limit of 100 degrees, and one for the rest of the year with an upper temperature limit of 90 degrees. The condition that has to be met for the squirrels to play is that the temperature should be between 60 and 90 degrees inclusively, unless it is summer, in which case the upper limit is expanded to 100 degrees.
To write code that represents this logic, one can use an if-else statement to distinguish between the two scenarios:
- If it is not summer (isSummer is false), the temperature must be between 60 and 90.
- If it is summer (isSummer is true), the temperature must be between 60 and 100.
In summary, using these conditions, the output would be as follows:
- squirrelPlay(70, false) should return true because 70 is between 60 and 90.
- squirrelPlay(95, false) should return false because 95 is above 90 and it is not summer.
- squirrelPlay(95, true) should return true because 95 is between 60 and 100 and it is summer.