Столкнулся со следующей проблемой. При прохождении курса Java fundamentals внутри intelij idea. Таска:
A programmer of a smart room system is asked to turn on the fan whenever the temperature goes over 24 and the dehumidifier whenever the humidity rises beyond 0.7 (70%).
However, if the smartMode option is turned on (true), only the fan may be activated.
In which of these situations the code does not work as intended?
Варианты ответа:
Select one or more options from the list:
When smart mode is on, humidity is 40% and temperature is 20.
When smart mode is off, humidity is 80% and temperature is 24.
When smart mode is off, humidity is 70% and temperature is 30.
When smart mode is on, humidity is 90% and temperature is 27.
Код:
public class SmartRoom
{
public static void main(String[] args)
{
double temperature; //in Celsius degrees
double humidity; //as a percentage
boolean smartMode;
/*
The previous variables have been assigned hidden values here.
*/
if (smartMode) //if smartMode is true, then...
{
if (humidity > 0.7) //if humidity is greater than 0.7 then...
System.out.println("Dehumidifier activated.");
else //else, if the humidity is lower, then...
System.out.println("Smart save mode on. Only fan activated.");
}
else //else, if smartMode is false, then...
{
if (humidity > 0.7) //if humidity is greater than 0.7 then...
System.out.println("Dehumidifier activated.");
else if (temperature > 24) //else, if the humidity is lower, then...
System.out.println("Fan activated.");
}
}
}
Считаю, что правильный ответ этот:
When smart mode is on, humidity is 90% and temperature is 27.
Если я не прав, опишите пожалуйста, почему.
"When smart mode is off, humidity is 70% and temperature is 30." answer to be checked to evaluate the solution as correct, meanwhile in this third scenario the smart room should function as intended.