Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4.10 Assignment: HVAC Controller Many homes nowadays are equipped with what is k

ID: 3752282 • Letter: 4

Question

4.10 Assignment: HVAC Controller Many homes nowadays are equipped with what is known as a dual zone Heating, Ventilation, and Air Conditioning (HVAC) system. There is usually one thermostat upstairs and one downstairs, so each floor can be heated or cooled separately The thermostat is the little control panel on the wall where you can set the desired temperature. There is a controller in the attic that handles the logic of when to run the AC when to run the furnace, and which floor to allow air flow into. The air flow is controlled by what is called a damper. The damper is a valve that either opens or closes the pipe where air flows into a floor There is one damper on each floor You will write the code for a hyptothetical dual zone HVAC controller, Here are the requirements Initialize the zone 1 temperature and zone 1 thermostat to 75 degrees Initialize the zone 2 temperature and zone 2 thermostat to 80 degrees Initialize the controller status to HVAC OFF Initialize both dampers to CLOSED Run a loop that prints the status of the system and asks for user input with the following numerical menu Status: HVAC OFF Zone 1 the rmogtat:7 Zone 2 thermostat: 80 Zone 1 damper is CLOSED Zone 2 danpoe ctosk

Explanation / Answer

#include <iostream>

using namespace std;

int main()

{

int userMenuChoice = 0;

int zone1Temperature = 75; ///current zone 1 temperature

int zone1Thermostat = 75; ///desired zone 1 temperature

int zone2Temperature = 80; ///current zone 2 temperature

int zone2Thermostat = 80; ///desired zone 2 temperature

enum DamperStatus {OPEN, CLOSED};

DamperStatus zone1DS = CLOSED;

DamperStatus zone2DS = CLOSED;

enum HvacStatus {OFF, AC, FURNACE};

HvacStatus Hvac = OFF;

do

{

cout << "Status: " << endl;

if (Hvac == OFF)

{

cout << "HVAC OFF" << endl;

}

if (Hvac == AC)

{

cout << "AC ON" << endl;

}

if (Hvac == FURNACE)

{

cout << "Furnace ON" << endl;

}

cout << "Zone 1 damper is ";

if (zone1DS == OPEN)

{

cout << "OPEN" << endl;

}

else

{

cout << "CLOSED" << endl;

}

cout << "Zone 2 damper is ";

if (zone2DS == OPEN)

{

cout << "OPEN" << endl;

}

else

{

cout << "CLOSED" << endl;

}

cout << "Zone 1 temperature: " << zone1Temperature << endl;

cout << "Zone 2 temperature: " << zone2Temperature << endl;

cout << "Enter a menu choice: " << endl;

cout << "0) Quit" << endl;

cout << "1) Set thermostats" << endl;

cout << "2) Wait 1 turn" << endl;

cout << "3) Wait 10 turns" << endl;

cin >> userMenuChoice;

switch (userMenuChoice)

{

case 0: ///Quit

break;

case 1: ///Set thermostats

cout << "Set the thermostat for zone 1: ";

cin >> zone1Thermostat;

cout << "Set the thermostat for zone 2: ";

cin >> zone2Thermostat;

break;

case 2: /// Wait 1 turn

if (zone1Temperature > zone1Thermostat)

{

zone1Temperature = zone1Temperature - 1;

}

if (zone1Temperature < zone1Thermostat)

{

zone1Temperature = zone1Temperature + 1;

}

if (zone2Temperature > zone2Thermostat)

{

zone2Temperature = zone2Temperature - 1;

}

if (zone2Temperature < zone2Thermostat)

{

zone2Temperature = zone2Temperature + 1;

}

break;

case 3: /// Wait 10 turns

///increment of decrement by 10 degrees based on thermostat

if (zone1Temperature > zone1Thermostat)

{

for (int i = 0; i < 10; i++)

{

zone1Temperature = zone1Temperature - 1;

if (zone1Temperature == zone1Thermostat)

{

break;

}

}

}

if (zone1Temperature < zone1Thermostat)

{

for (int i = 0; i < 10; i++)

{

zone1Temperature = zone1Temperature + 1;

if (zone1Temperature == zone1Thermostat)

{

break;

}

}

}

if (zone2Temperature > zone2Thermostat)

{

for (int i = 0; i < 10; i++)

{

zone2Temperature = zone2Temperature - 1;

if (zone2Temperature == zone2Thermostat)

{

break;

}

}

}

if (zone2Temperature < zone2Thermostat)

{

for (int i = 0; i < 10; i++)

{

zone2Temperature = zone2Temperature + 1;

if (zone2Temperature == zone2Thermostat)

{

break;

}

}

}

break;

}

///Damper Status

if ((zone1Temperature > zone1Thermostat) || (zone1Temperature < zone1Thermostat))

{

zone1DS = OPEN;

}

if (zone1Temperature == zone1Thermostat)

{

zone1DS = CLOSED;

}

if ((zone2Temperature > zone2Thermostat) || (zone2Temperature < zone2Thermostat))

{

zone2DS = OPEN;

}

if (zone2Temperature == zone2Thermostat)

{

zone2DS = CLOSED;

}

///HVAC Status

if ((zone1Temperature < zone1Thermostat) || (zone2Temperature < zone2Thermostat))

{

Hvac = FURNACE;

}

if ((zone1Temperature > zone1Thermostat) || (zone2Temperature > zone2Thermostat))

{

Hvac = AC;

}

if ((zone1DS == CLOSED) && (zone2DS == CLOSED))

{

Hvac = OFF;

}

} while (userMenuChoice != 0);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote