Project 2 - Implement the Code for controlling the retraction and extension of Airplane’s landing gear
#include
#include
/*variables*/
int take_f_state=0;
int lan_f_state=0;
int f_hight=250;
int f_wheel=1;
char name_1[]="take_off";
char name_2[]="landing";
/*function prototype*/
void take__off();
void landing();
int main()
{
char pro[10];//local variable
printf("enter the process:");
scanf("%s",pro);//get input from user
if((strcmp(pro,name_1))==0);// check the condition
{
while(1)// run until the process
{
take__off();
if(take_f_state==5)//check the condition
{
take_f_state=0;
break;
}
}
}
if((strcmp(pro,name_2))==0);//check the condition
{
while(1) //run until the process is end
{
landing();
if(lan_f_state5)// check the condition
{
lan_f_state=0;
break;
}
}
}
}
void landing()//function definition
{
switch(lan_f_state)
{
case 0:
printf("extended process start..,n");//first state
lan_f_state=1;
break;
case 1:
if(f_hight>200)//check the hight
{
printf("proper hight is reached n");
lan_f_state=2;
}
else//else wait for hight is reached
{
printf("waiting for proper hight to reach...");
}
break;
case 3:
printf("lever is activatedn");//activated the lever
printf("hydralic pump vaue is changedn");// change the value
lan_f_state=4;
break;
case 4:
if(f_wheel==1)//check the wheel position
{
printf("wheel is properly get outn");
printf("extended process is complete");
lan_f_state=5;
}
else//wait for wheel get in
{
printf("wait for wheel get out...");
}
break;
case 2:
printf("door openn");//close the door
lan_f_state=3;
break;
}
}
void take__off()//function definition
{
switch(take_f_state)
{
case 0:
printf("retracted process start..,n");//first state
take_f_state=1;
break;
case 1:
if(f_hight>200)//check the hight
{
printf("proper hight is reached n");
take_f_state=2;
}
else//else wait for hight is reached
{
printf("waiting for proper hight to reach...");
}
break;
case 2:
printf("lever is activatedn");//activated the lever
printf("hydralic pump value is changedn");//change the value
take_f_state=3;
break;
case 3:
if(f_wheel==1)//check the wheel position
{
printf("wheel is properly get inn");
take_f_state=4;
}
else//wait for wheel get in
{
printf("wait for wheel get in...");
}
break;
case 4:
printf("door closedn");//close the door
printf("retracted process is completed");//process is completed
take_f_state=5;
break;
}
}