Nested if statements
Exercise Type: Implementation
Consider these statements:
-
If the temperature is below 15˚C, you should wear a jacket.
-
If the weather is rainy you should wear a jacket in general, but only if the temperature is lower than 25˚C.
For instance, for these parameters
# for example
temperature <- 17
raining <- FALSE
Should I wear a jacket or not?
Instructions
Implement a piece of code that calculates whether you need to wear a jacket or not based on any (realistic) values for temperature, and whether it rains or not? Use nested if
statements to write this piece of code!
If based on the rules above, a jacket is needed, print out the following message
:
Wear a jacket!
If not, then this:
Don't wear a jacket!