Ask coding questions

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

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 (916) [earned 5 cycles]
View Answer
Comments
hotnewtop
vedprad1 (916)

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 (916)

@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!

jeremyjameslv (2)

I gave this same answer and it said my answer did not match my teachers.

leciafosl (0)

In most cases, the air conditioner can be kept for only a short time without replacing it. If you leave it unattended for even a few minutes, the compressor might start to work and unleash a frighteningly loud noise that can hurt your ears. You should always call a few days ahead of time to let the air conditioner installer know that you plan to be away for an extended period. Most household air conditioners have a schedule that tells them when and where they need to be serviced. I had a similar case, and I was helped by the guys from socool.sg.

MagnoliaYY (0)

What to do when this A/C is broken?

Utantendi (0)

"It's quite a challenge. This program presents a simple thermostat based on the MSP430F41 MCU.
The MSP430 periodically reads the thermistor, displays the value on the LCD, and compares it with the set threshold. In addition, the device
The real-time clock, which can also be displayed on the LCD, is implemented.
The software automatically switches the screen to the temperature display mode after a specific time has elapsed.
The program automatically switches the screen to display the temperature after a specific time has elapsed. The user can change the threshold, which is also shown on the ; LCD
The user can change the threshold, which is also displayed on the LCD when it is set. You are advised to contact an air conditioning installation technician https://www.spartamech.co.uk/air-conditioning/."

CarolClark (0)

The exact answers, but teachers in their style: It's not correct! I'm just thinking of quitting college and go working to install ac. I would be better at it, at least if I can work with https://www.airconservicingsingapore.com/ guys. This team is coming each summer to our house to check the condition of our ac, to clean the dirty filters, and make a chemical overhaul. Why do I need hassle with coding and Java when I can become a real engineer. Didn't you guys think about reprofiling yourself? Or is programming too addictive?