Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
h>
#include<errno.h>
#include<stdlib.h>
#include<string.h>
#define string_length 20
float TotalRevenueCC;
float TotalAssetCC;
int Facility1;
float TotalRevenueSL;
float TotalAssetSL;
int Facility2;
float TotalRevenueBT;
float TotalAssetBT;
int Facility3;
struct AircraftInfo{
int id;
int modelnumber;
float height;
float length;
float wingspan;
float weight;
char engine[string_length];
float Storageduration;
float AssetWorth;
int Location;
float TransportCost;
float StorageFee;
};
int choice;
printf("============================================================\n\n ");
printf("============================================================\n\n ");
printf("============================================================\n\n ");
printf("============================================================\n\n ");
printf("Task=====>");
scanf("%d",&choice);
return choice;
}/*End Function*/
FILE*inDataFile1;
int f,result;
result=MenuChoice();
}//END IF
else
fwrite(&property,sizeof(struct AircraftInfo),1,inDataFile1);
} //END FOR
fclose(inDataFile1);
}//END ELSE
int result;
FILE*inDataFile1;
float UtilCost1=1200.75;
float EmployCost1=30000.00;
float Tax1=5600.0;
float StorageRate1=20000.50;
float UtilCost2=370.00;
float EmployCost2=15000.00;
float Tax2=1000.00;
float StorageRate2=40000.00;
float UtilCost3=2300.50;
float EmployCost3=18900.75;
float Tax3=1500.00;
float StorageRate3=37500.50;
struct AircraftInfo property={0,"","",0,0.0,0.0,0.0,0.0,"",0.0,0.0,0,0.0,0.0};
result=MenuChoice();
}/*ENDIF*/
scanf("%d",&property.id);
scanf("%s",&property.model_name);
scanf("%s",&property.customer_name);
scanf("%f",&property.height);
exit(1);//Terminates program
scanf("%f",&property.length);
exit(1);//Terminates program
scanf("%f",&property.wingspan);
if (property.wingspan<20)//User cannot enter value below 20
exit(1);//Terminates program
scanf("%f",&property.weight);
exit(1);//Terminates program
scanf("%s",&property.engine);
scanf("%f",&property.Storageduration);
{
printf("\n\nThis is invalid information!\n\n");
exit(1);//Terminates program
scanf("%f",&property.AssetWorth);
exit(1);//Terminates program
printf("\t+++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
printf("\t+++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
printf("\t+++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
scanf("%d",&property.Location);
if(property.Location==1)
if (Facility1!=2)
Facility1=Facility1+1;
property.TransportCost=2590.00;
property.StorageFee=StorageRate1*property.Storageduration+(0.1*(UtilCost1+EmployCost1+Tax1));
TotalAssetCC=TotalAssetCC+property.AssetWorth;
TotalRevenueCC=TotalRevenueCC+property.StorageFee+property.TransportCost;
}//END IF
else
printf("That storage facility is full, we are sorry for this inconvenience\n Please enjoy your
day!");//This location is full
exit(1);//Terminates program
}//END ELSE
}//END IF
else
if (property.Location==2)
if (Facility2!=2)
Facility2=Facility2+1;
property.TransportCost=4122.00;
property.StorageFee=StorageRate2*property.Storageduration+(0.1*(UtilCost2+EmployCost2+Tax2));
TotalAssetSL=TotalAssetSL+property.AssetWorth;
TotalRevenueSL=TotalRevenueSL+property.StorageFee+property.TransportCost;
}//END IF
else
printf("That storage facility is full, we are sorry for this inconvenience\n Please enjoy your
day!");//This location is full
exit(1);//Terminates program
}//END ELSE
}//END IF
else
if (property.Location==3)
if (Facility3!=2)
Facility3=Facility3+1;
property.TransportCost=2600.00;
property.StorageFee=StorageRate3*property.Storageduration+(0.1*(UtilCost3+EmployCost3+Tax3));
TotalAssetBT=TotalAssetBT+property.AssetWorth;
TotalRevenueBT=TotalRevenueBT+property.StorageFee+property.TransportCost;
}//END IF
else
printf("That storage facility is full, we are sorry for this inconvenience\n Please enjoy your
day!");//This location is full
exit(1);//Terminates program
}//END ELSE
}//END IF
else
//ERROR-HANDLING
if((property.Location!=1)&&(property.Location!=2)&&(property.Location!=3))
exit(1);//Terminates program
}//END IF
fseek(inDataFile1,(property.id-1)*sizeof(struct AircraftInfo),SEEK_SET);
fwrite(&property,sizeof(struct AircraftInfo),1,inDataFile1);
fclose(inDataFile1);
system("Pause");
FILE*inDataFile1;
}//END IF
else
printf("============================================================\n\n ");
printf("============================================================\n\n");
while(!feof(inDataFile1))
{
fread(&property,sizeof(struct AircraftInfo),1,inDataFile1);
if(property.id!=0)
printf("Customer ---->%s\n",property.customer_name);
printf("Engine ------>%s\n\n",property.engine);
if (property.Location==1)
else
if (property.Location==2)
}//ENDIF
else
if (property.Location==3)
}//ENDIF
printf("\n\n\n");
printf("============================================================\n\n \n");
}//END IF
}//END WHILE
}//END ELSE
fclose(inDataFile1);
system("Pause");
FILE*inDataFile1;
int searchid;
int result;
result=MenuChoice();
}//END IF
else
printf("SEARCH RECORDS");
scanf("%d",&searchid);
fseek(inDataFile1,(searchid-1)*sizeof(struct AircraftInfo),SEEK_SET);
if(property.id!=0)
if (searchid==property.id)
printf("Engine ------>%s\n\n",property.engine);
if (property.Location==1)
else
if (property.Location==2)
else
if (property.Location==3)
}//ENDIF
if(property.id==0)
//END IF
fclose(inDataFile1);
system("Pause");
}//END ELSE
}//ENDIF
FILE*inDataFile1;
int identification;
int result;
int upchoice;
float heightamount;
float lengthamount;
float wingspanamount;
float weightamount;
float assetworthamount;
float storageamount;
float UtilCost1=1200.75;
float EmployCost1=30000.00;
float Tax1=5600.0;
float StorageRate1=20000.50;
float UtilCost2=370.00;
float EmployCost2=15000.00;
float Tax2=1000.00;
float StorageRate2=40000.00;
float UtilCost3=2300.50;
float EmployCost3=18900.75;
float Tax3=1500.00;
float StorageRate3=37500.50;
float TotalRevenueCC=0.0;
float TotalRevenueSL=0.0;
float TotalRevenueBT=0.0;
result=MenuChoice();
}//END IF
else
fseek(inDataFile1,(identification-1)*sizeof(struct AircraftInfo),SEEK_SET);
if(property.id==0)
}//END IF
if(property.id!=0)
printf("Customer ---->%s",property.customer_name);
printf("Engine -------->%s",property.engine);
printf("Task=====>");
scanf("%d",&upchoice);
while(upchoice!=7)
{
if (upchoice==1)
printf(".......Updating Height......");
scanf("%f",&heightamount);
property.height=property.height+heightamount;
if (property.height<5)
property.height=property.height-heightamount;
break;
else
break;
printf(".......Updating Length......");
scanf("%f",&lengthamount);
property.length=property.length+lengthamount;
if (property.length<20)
property.length=property.length-lengthamount;
break;
else
break;
if (upchoice==3)//WINGSPAN UPDATE
{
printf(".......Updating Wingspan......");
scanf("%f",&wingspanamount);
property.wingspan=property.wingspan+wingspanamount;
if (property.wingspan<20)
property.wingspan=property.wingspan-wingspanamount;
break;
else
break;
if (upchoice==4)//WEIGHT UPDATE
{
printf(".......Updating Weight......");
scanf("%f",&weightamount);
property.weight=property.weight+weightamount;
if (property.weight<200)
property.weight=property.weight-weightamount;
break;
else
break;
property.AssetWorth=property.AssetWorth+assetworthamount;
if (property.AssetWorth<50000)
property.AssetWorth=property.AssetWorth-assetworthamount;
break;
else
break;
scanf("%f",&storageamount);
property.Storageduration=property.Storageduration+storageamount;
if (property.Storageduration<1)
property.Storageduration=property.Storageduration-storageamount;
break;
else
break;
if (upchoice==7)//ABORT UPDATE
break;
if ((upchoice<1)||(upchoice>7))//ERROR-HANDLING
printf("Invalid Option!\n\n\n\n");
exit(1);
if (property.Location==1)
TotalRevenueCC=TotalRevenueCC-property.StorageFee;
property.StorageFee=StorageRate1*property.Storageduration+(0.1*(UtilCost1+EmployCost1+Tax1));
TotalRevenueCC=TotalRevenueCC+property.StorageFee;
else
if (property.Location==2)
TotalRevenueSL=TotalRevenueSL-property.StorageFee;
property.StorageFee=StorageRate2*property.Storageduration+(0.1*(UtilCost2+EmployCost2+Tax2));
TotalRevenueSL=TotalRevenueSL+property.StorageFee;
else
if (property.Location==3)
TotalRevenueBT=TotalRevenueBT-property.StorageFee;
property.StorageFee=StorageRate3*property.Storageduration+(0.1*(UtilCost1+EmployCost3+Tax3));
TotalRevenueBT=TotalRevenueBT+property.StorageFee;
printf("======================================================\n");
printf("======================================================\n");
printf("Customer ---->%s\n",property.customer_name);
printf("Engine -------->%s\n\n",property.engine);
fwrite(&property,sizeof(struct AircraftInfo),1,inDataFile1);
fclose(inDataFile1);
FILE*inDataFile1;
int identification;
int result;
}//END IF
else
scanf("%d",&identification);
fseek(inDataFile1,(identification-1)*sizeof(struct AircraftInfo),SEEK_SET);
fread(&property,sizeof(struct AircraftInfo),1,inDataFile1);
if(property.id==0)
}//END IF
if(property.id!=0)
if (property.Location==1)
Facility1=Facility1-1;
TotalRevenueCC=TotalRevenueCC-(property.TransportCost+property.StorageFee);
TotalAssetCC=TotalAssetCC-property.AssetWorth;
else
if (property.Location==2)
Facility2=Facility2-1;
TotalRevenueSL=TotalRevenueSL-(property.TransportCost+property.StorageFee);
TotalAssetSL=TotalAssetSL-property.AssetWorth;
else
if (property.Location==3)
Facility3=Facility3-1;
TotalRevenueBT=TotalRevenueBT-(property.TransportCost+property.StorageFee);
TotalAssetBT=TotalAssetBT-property.AssetWorth;
fseek(inDataFile1,(property.id-1)*sizeof(struct AircraftInfo),SEEK_SET);
fwrite(&blankproperty,sizeof(struct AircraftInfo),1,inDataFile1);
printf("============================================================\n\n ");
printf("============================================================\n\n ");
}//END IF
fclose(inDataFile1);
system("Pause");
}//END ELSE
FILE*inDataFile1;
float UtilCost1=1200.75;
float EmployCost1=30000.00;
float Tax1=5600.0;
float UtilCost2=370.00;
float EmployCost2=15000.00;
float Tax2=1000.00;
float UtilCost3=2300.50;
float EmployCost3=18900.75;
float Tax3=1500.00;
float CCOpExp;
float SLOpExp;
float BTOpExp;
float CCNetIncome;
float SLNetIncome;
float BTNetIncome;
int input;
}//END IF
else
printf("============================================================\n\n");
scanf("%d",&input);
if(input==1)
CCOpExp=Tax1+EmployCost1+UtilCost1;
CCNetIncome=TotalRevenueCC-CCOpExp;
else
if (input==2)
SLOpExp=Tax2+EmployCost2+UtilCost2;
SLNetIncome=TotalRevenueSL-SLOpExp;
else
if(input==3)
BTOpExp=Tax3+EmployCost3+UtilCost3;
BTNetIncome=TotalRevenueBT-BTOpExp;
else
if((input>3)||(input<1))//ERROR-HANDLING
printf("Invalid Input!");
}
}//END ELSE
fclose(inDataFile1);
FILE*inDataFile1;
float UtilCost1=1200.75;
float EmployCost1=30000.00;
float Tax1=5600.0;
float UtilCost2=370.00;
float EmployCost2=15000.00;
float Tax2=1000.00;
float UtilCost3=2300.50;
float EmployCost3=18900.75;
float Tax3=1500.00;
float CCOpExp;
float SLOpExp;
float BTOpExp;
float CCNetIncome;
float SLNetIncome;
float BTNetIncome;
float Expenses;
float Revenue;
float NetIncome;
float Assets;
}//END IF
else
CCOpExp=Tax1+EmployCost1+UtilCost1;
CCNetIncome=TotalRevenueCC-CCOpExp;
SLOpExp=Tax1+EmployCost1+UtilCost1;
SLNetIncome=TotalRevenueSL-SLOpExp;
printf("\n\t======================================\n\n\n");
BTOpExp=Tax1+EmployCost1+UtilCost1;
BTNetIncome=TotalRevenueBT-BTOpExp;
printf("\t=======================================\n");
Assets=TotalAssetCC+TotalAssetSL+TotalAssetBT;
Expenses=CCOpExp+SLOpExp+BTOpExp;
Revenue=TotalRevenueCC+TotalRevenueSL+TotalRevenueBT;
NetIncome=Revenue-Expenses;
system("Pause");
printf("\n\n");
printf("\t============================================");
printf("\n\n");
printf("\tFINANCIAL SUMMARY");
printf("\n\n");
printf("\t============================================\n\n");
printf("\tNet Income-------------------->$%.2f\n\n",NetIncome);
fclose(inDataFile1);
}//END ELSE
main()//MAIN PROGRAM
{
char pass[10];
printf("Enter a password\n\n");
scanf("%s",pass);
while (strcmp(pass,"WE")!=0)
scanf("%s",pass);
}//ENDIF
FILE*inDataFile1;//POINTER TO FILE
int identification,result,f;
float heightamount;
float lengthamount;
float wingspanamount;
float weightamount;
float assetworthamount;
float storageamount;
float UtilCost1=1200.75;
float EmployCost1=30000.00;
float Tax1=5600.0;
float StorageRate1=20000.50;
float UtilCost2=370.00;
float EmployCost2=15000.00;
float Tax2=1000.00;
float StorageRate2=40000.00;
float UtilCost3=2300.50;
float EmployCost3=18900.75;
float Tax3=1500.00;
float StorageRate3=37500.50;
float CCOpExp;
float SLOpExp;
float BTOpExp;
float CCNetIncome;
float SLNetIncome;
float BTNetIncome;
float Expenses;
float Revenue;
float NetIncome;
float Assets;
int searchid;
int input;
int upchoice;
while(result!=9)
if(result==1)
CreateFile();
system("Pause");
}//END IF
AddInfo();
result=MenuChoice();/*call to function MenuChoice*/
}//END IF
if(result==3)//VIEW RECORDS
ViewInfo();
result=MenuChoice();
}//END IF
Search();
result=MenuChoice();
}//END IF
if(result==5)//UPDATING RECORDS
UpdateRecord();
if(result==6)//DELETING RECORDS
Delete();
result=MenuChoice();
}//END IF
if(result==7)//VIEW LOCATION
ViewLocation();
result=MenuChoice();
Company();
result=MenuChoice();
}//END IF
system("pause");
}//END IF
if((result>9)||(result<=0))//ERROR-HANDLING
printf("\t\t\tInvalid Input!");
system("Pause");
result=MenuChoice();
} //END WHILE
}//END MAIN