Ask coding questions

← Back to all posts
conditionals and options
Triecie77 (0)

Write a program for your smart thermostat. Do the following using a temperature, isRaining, and isOn property,

If the temperature is less than 68 degrees or it is raining, the Air Conditioning should be turned off. Otherwise the Air Conditioning should be turned on.

Try different combinations of temperatures and weather conditions (raining vs not raining) to make sure your thermostat works correctly.

Use a print statement to check the air conditioning's status.
let temperature = 68

If temperature < 68 {
print("the Air Conditioning should be turned off")

}else if temperature >= 68
print("the air conditioning should be turned on")

Answered by vedprad1 (694) [earned 5 cycles]
View Answer
Commentshotnewtop
vedprad1 (694)

Well, you have a quiet a few problems with this, but let's start with this question:
What language is this?
It seems like you are combining Python and JavaScript.

vedprad1 (694)

@Triecie77 : Then you have three problems:
1. The If should be lowercase, like this: if.
2. You do not need an else if, just an else.
3. The second print should also be surrounded by braces, like this: {}.

Your final product should look like this:

let temperature = 68

if temperature < 68 {
print("the Air Conditioning should be turned off")

}else {
print("the air conditioning should be turned on")
}

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!