...

/

Making Decisions with AI

Making Decisions with AI

Learn Java if/else statements by building a smart thermostat that decides whether to activate the heater or air conditioning.

The project

You’ve just moved into a comfortable neighborhood, but your new home needs an upgrade to its automated temperature control system. At the moment, the thermostat is fairly basic; it can’t determine whether to turn on the air-conditioning or the heater. A static display that simply says “Temperature is 25” isn’t very useful. What you really need is a system that can make decisions based on the temperature and your individual comfort level.

With growing confidence in your Java skills, you’re ready to build the thermostat logic yourself. This smart home system will compare the current room temperature with the user’s preferred comfort level and decide what action to take.

The programming concept

Imagine this:

You're writing a program that checks a person’s age and responds accordingly:

  1. “You can vote!” if the person is 18 or older.

  2. “Sorry, too young,” if they’re younger than 18.

How would you say that in plain English?

If the age is 18 or more → say ...