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); } } --------------------------------------------------------------------------------------------------------------------------------------------------------
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...
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.
- 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 <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);
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 7 steps with 8 images
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY