In this lab session, you are going to improvement a simulator for an air conditioner. Users can select sort of actions that the air conditioner allows. Turn air conditioner On/Off Increase fan speed by 100  Decrease fan speed by 100  Change to mode of cooling: On/Off  Increment the temperature degree of the air conditioner  Decrement the temperature degree of the air conditioner  Exit the program: -------------------------------------------------------------------------------------------------------------------------------------------------------- #include #define true 1 #definefalse0 #define MinFan 100 #define MaxFan 1000 #defineMinCool18 #define MaxCool 30 typedef int bool; typedef struct AirConditionerStruct { bool status; // running status struct FanStruct{ bool flow; int fanSpeed; } fanControl; struct ModeStrcut{ bool cooling; int degree;     } coolingControl;     }AirConditioner;  void changeStatus (AirConditioner *airPtr); void increaseFanSpeed (AirConditioner *airPtr, int maxLimit); void decreaseFanSpeed (AirConditioner *airPtr, int minLimit); void changeMode(AirConditioner *airPtr); void incrementDegree(AirConditioner *airPtr, int maxLimit); void decrementDegree(AirConditioner *airPtr, int minLimit); void printAirConditionerStatus(AirConditioner *airPtr);  int main(void) {     bool exit = false;     int choice;     AirConditioner aircondobject;     while( !exit) {         printf( "\n-------------\n");         printf( "1) Turn air conditioner ON/OFF?\n");         printf( "2) Increase air conditioner fan?\n" );         printf( "3) Decrease air conditioner fan?\n" );         printf( "4) Change air conditioner mode?\n" );         printf( "5) Increment temperature degree?\n" );         printf( "6) Decrement temperature degree?\n" );         printf( "7) Exit..!\n" );         scanf ( "%d" , &choice);         switch( choice ){              case 1: changeStatus(&aircondobject); break;              case 2: increaseFanSpeed(&aircondobject, MaxFan); break;              case 3: decreaseFanSpeed(&aircondobject, MinFan); break;              case 4: changeMode (&aircondobject); break;              case 5: incrementDegree(&aircondobject, MaxCool); break;              case 6: decreaseFanSpeed (&aircondobject, MinCool); break;              case 7: exit = true; break;              default: printf( "Invalid selection of option. Try again!\n" );               }               if( !exit )                     printAirConditionerStatus (&aircondobject);     }  } void printAirConditionerStatus (AirConditioner *airPtr) {     printf("\nAir conditioner status: %s\n", airPtr->status ? "Running" : "Standby" );  if(airPtr->fanControl.flow){     printf("|\tFan speed = %d\n", airPtr->fanControl.fanSpeed);     }     if(airPtr->coolingControl.cooling){         printf("|\tTemperature degree: %d\n", airPtr->coolingControl.degree);     } } --------------------------------------------------------------------------------------------------------------------------------------------------------

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In this lab session, you are going to improvement a simulator for an air conditioner. Users can select sort of actions that the air conditioner allows.

  1. Turn air conditioner On/Off
  2. Increase fan speed by 100 
  3. Decrease fan speed by 100 
  4. Change to mode of cooling: On/Off 
  5. Increment the temperature degree of the air conditioner 
  6. Decrement the temperature degree of the air conditioner 
  7. Exit the program:
--------------------------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#define true 1
#definefalse0
#define MinFan 100
#define MaxFan 1000
#defineMinCool18
#define MaxCool 30
typedef int bool;
typedef struct AirConditionerStruct {
bool status; // running status
struct FanStruct{
bool flow;
int fanSpeed;
} fanControl;
struct ModeStrcut{ bool cooling; int degree;
    } coolingControl;
    }AirConditioner;
 void changeStatus (AirConditioner *airPtr);
void increaseFanSpeed (AirConditioner *airPtr, int maxLimit);
void decreaseFanSpeed (AirConditioner *airPtr, int minLimit);
void changeMode(AirConditioner *airPtr);
void incrementDegree(AirConditioner *airPtr, int maxLimit);
void decrementDegree(AirConditioner *airPtr, int minLimit);
void printAirConditionerStatus(AirConditioner *airPtr);

 int main(void) {
    bool exit = false;
    int choice;
    AirConditioner aircondobject;
    while( !exit) {
        printf( "\n-------------\n");
        printf( "1) Turn air conditioner ON/OFF?\n");
        printf( "2) Increase air conditioner fan?\n" );
        printf( "3) Decrease air conditioner fan?\n" );
        printf( "4) Change air conditioner mode?\n" );
        printf( "5) Increment temperature degree?\n" );
        printf( "6) Decrement temperature degree?\n" );
        printf( "7) Exit..!\n" );
        scanf ( "%d" , &choice);
        switch( choice ){
             case 1: changeStatus(&aircondobject); break;
             case 2: increaseFanSpeed(&aircondobject, MaxFan); break;
             case 3: decreaseFanSpeed(&aircondobject, MinFan); break;
             case 4: changeMode (&aircondobject); break;
             case 5: incrementDegree(&aircondobject, MaxCool); break;
             case 6: decreaseFanSpeed (&aircondobject, MinCool); break;
             case 7: exit = true; break;
             default: printf( "Invalid selection of option. Try again!\n" );
              }
              if( !exit )
                    printAirConditionerStatus (&aircondobject);
    }
 }

void printAirConditionerStatus (AirConditioner *airPtr) {
    printf("\nAir conditioner status: %s\n", airPtr->status ? "Running" : "Standby" );
 if(airPtr->fanControl.flow){
    printf("|\tFan speed = %d\n", airPtr->fanControl.fanSpeed);
    }
    if(airPtr->coolingControl.cooling){
        printf("|\tTemperature degree: %d\n", airPtr->coolingControl.degree);
    }
}
--------------------------------------------------------------------------------------------------------------------------------------------------------
Task 1.5: Define the function
void incrementDegree(AirConditioner *airPtr, int maxLimit)
that increment the temperature degree of the air condition by 1 unit if and only if the running status of the
air conditioner is ON and the result temperature degree doesn't exceed the maximum limit of the
temperature. Otherwise, display the following message: "The air conditioner cooling temperature has
reached the maximum limit."
If the running status of the air conditioner is OFF, then display the following message: "The air
conditioner is OFF."
Task 1.6: Define the function
void decrementDegree(AirConditioner *airPtr, int minLimit) that decrement the temperature degree
of the air condition by 1 unit if and only if the running status of the air conditioner is ON and the result
temperature degree doesn't go below the minimum limit of the temperature. Otherwise, display the
following message: "The air conditioner cooling temperature has reached the minimum limit."
If the running status of the air conditioner is OFF, then display the following message: "The air
conditioner is OFF."
Transcribed Image Text:Task 1.5: Define the function void incrementDegree(AirConditioner *airPtr, int maxLimit) that increment the temperature degree of the air condition by 1 unit if and only if the running status of the air conditioner is ON and the result temperature degree doesn't exceed the maximum limit of the temperature. Otherwise, display the following message: "The air conditioner cooling temperature has reached the maximum limit." If the running status of the air conditioner is OFF, then display the following message: "The air conditioner is OFF." Task 1.6: Define the function void decrementDegree(AirConditioner *airPtr, int minLimit) that decrement the temperature degree of the air condition by 1 unit if and only if the running status of the air conditioner is ON and the result temperature degree doesn't go below the minimum limit of the temperature. Otherwise, display the following message: "The air conditioner cooling temperature has reached the minimum limit." If the running status of the air conditioner is OFF, then display the following message: "The air conditioner is OFF."
Task 1.1: Define the function:
void changeStatus (AirConditioner *airPtr)
That turns the air conditioner ON or OFF according to the following conditions:
If the air conditioner is at standby mode, then the function sets the running status to ON, enables the fan
flow and puts the fan speed to the minimum speed. Also, the mode cooling system must be set ON.
If the air conditioner is on running mode, then the function sets the running status to OFF, the air
condition fan flow to OFF. The cooling mode must be put also to OFF.
Task 1.2: Define the function:
void increaseFanspeed (AirConditioner *airPtr, int maxLimit)
The function does the following If running status of the air conditioner is ON, then increase the air
conditioner fan speed by 100 if and only if the result fan speed is below maxLimit. If the air conditioner
fan speed was about to exceed the maxLimit then display the following message: "The air conditioner fan
speed has reached the maximum limit."
If the running status of the air conditioner is OFF, then display the following message: "The air
conditioner is OFF"
Task 1.3: Define the function:
void decreaseFanspeed (AirConditioner *airPtr, int minLimit)
The function does the following
If running status of the air conditioner is ON, then decrease the air conditioner fan speed by 100 if and
only if the result fan speed is above minLimit. If the air conditioner fan speed was about to be below
minLimit, then display the following message: "The air conditioner fan speed has reached the minimum
limit."
If the running status of the air conditioner is OFF, then display the following message: "The air
conditioner is OFF."
Task 1.4: Define the function
void changeMode(AirConditioner *airPtr);
that changes the cooling mode of the air conditioner to ON or OFF according to the following conditions:
If the running status of air conditioner is ON and the cooling status is also ON, then put the air condition
cooling status to OFF.
If the running status of the air conditioner is ON and the cooling status is OFF, then put the air condition
cooling status to ON.
If the running status of the air conditioner is OFF, then display the following message: "The air
conditioner is OFF."
Transcribed Image Text:Task 1.1: Define the function: void changeStatus (AirConditioner *airPtr) That turns the air conditioner ON or OFF according to the following conditions: If the air conditioner is at standby mode, then the function sets the running status to ON, enables the fan flow and puts the fan speed to the minimum speed. Also, the mode cooling system must be set ON. If the air conditioner is on running mode, then the function sets the running status to OFF, the air condition fan flow to OFF. The cooling mode must be put also to OFF. Task 1.2: Define the function: void increaseFanspeed (AirConditioner *airPtr, int maxLimit) The function does the following If running status of the air conditioner is ON, then increase the air conditioner fan speed by 100 if and only if the result fan speed is below maxLimit. If the air conditioner fan speed was about to exceed the maxLimit then display the following message: "The air conditioner fan speed has reached the maximum limit." If the running status of the air conditioner is OFF, then display the following message: "The air conditioner is OFF" Task 1.3: Define the function: void decreaseFanspeed (AirConditioner *airPtr, int minLimit) The function does the following If running status of the air conditioner is ON, then decrease the air conditioner fan speed by 100 if and only if the result fan speed is above minLimit. If the air conditioner fan speed was about to be below minLimit, then display the following message: "The air conditioner fan speed has reached the minimum limit." If the running status of the air conditioner is OFF, then display the following message: "The air conditioner is OFF." Task 1.4: Define the function void changeMode(AirConditioner *airPtr); that changes the cooling mode of the air conditioner to ON or OFF according to the following conditions: If the running status of air conditioner is ON and the cooling status is also ON, then put the air condition cooling status to OFF. If the running status of the air conditioner is ON and the cooling status is OFF, then put the air condition cooling status to ON. If the running status of the air conditioner is OFF, then display the following message: "The air conditioner is OFF."
Expert Solution
steps

Step by step

Solved in 7 steps with 8 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY