/************************************************/ /* ECE-1011 Spring 2003 */ /* Section:......... 0 */ /* Assignment:...... 1 */ /* Programmer:...... BAHN, William L. */ /* File Contents:... SOURCE CODE */ /* Filename:........ s10_key */ /* Due Date:........ 03 Feb 03 */ /* E-mail Address:.. wbahn@eas.uccs.edu */ /************************************************/ /*============== STANDARD LIBRARY INCLUDE FILES =============================*/ #include /* printf(), scanf() */ /*============== PROGRAMMER DEFINED CONSTANTS ===============================*/ /*****************************************************************************/ /* Version and Author Control */ /*****************************************************************************/ #define VERSION (1) #define REVISION (1) #define PROGRAMMER "William L. Bahn" #define LASTMODDATE "16 FEB 2003" /*****************************************************************************/ /* Parameters for a particular type of aircraft */ /*****************************************************************************/ /* AIRCRAFT_TYPE "Text String Description" */ /* MIN_GROSS (Minimum Gross Weight in pounds) */ /* MAX_GROSS (Maximum Gross Weight in pounds) */ /* FWD_CG_MINGW (Fwd CG Limit @ MIN_GROSS) */ /* FWD_CG_MAXGW (Fwd CG Limit @ MAX_GROSS) */ /* FWD_CG_BRKGW (Weight at which FWD CG begins changing) */ /* AFT_CG_MINGW (AFT CG Limit @ MIN_GROSS) */ /* AFT_CG_MAXGW (AFT CG Limit @ MAX_GROSS) */ /* AFT_CG_BRKGW (Weight at which AFT CG begins changing) */ /*****************************************************************************/ #define AIRCRAFT_TYPE "T41-B" #define MIN_GROSS (1500.0) #define MAX_GROSS (2500.0) #define FWD_CG_MINGW (35.0) #define FWD_CG_MAXGW (40.5) #define FWD_CG_BRKGW (1950.0) #define AFT_CG_MINGW (47.0) #define AFT_CG_MAXGW (47.0) #define AFT_CG_BRKGW (2500.0) /*****************************************************************************/ /*===========================================================================*/ /*=========================== MAIN FUNCTION =================================*/ /*===========================================================================*/ int main(void) { /* Variable Dictionary */ double empty_wt, empty_cg; /* Aircraft Empty Weight and CG */ double fuel_wt, fuel_cg; /* Fuel Weight and CG */ double frontpax_wt, frontpax_cg; /* Front Occupants Weight and CG */ double rearpax_wt, rearpax_cg; /* Rear Occupants Weight and CG */ double baggage_wt, baggage_cg; /* Baggage Area Weight and CG */ double misc_wt, misc_cg; /* Misc. Items Weight and CG */ double gross_wt, gross_cg, gross_mom; /* Total A/C Weight, CG, and Moment */ /* Section 1 - Print out Aircraft Parameters -----------------------------*/ printf("===============================================================\n"); printf("Aircraft CG Calculator Version %i.%i\n", VERSION, REVISION); printf("Programmer: %s\n", PROGRAMMER); printf("Date of Last Mod: %s\n", LASTMODDATE); printf("===============================================================\n"); printf("This program computes the weight and balance for an aircraft\n"); printf("described by the following CG Envelope:\n"); printf("\n"); printf("Aircraft Type: %s\n", AIRCRAFT_TYPE); printf("\n"); printf("Gross Weight Limitations:\n"); printf(" The minimum aircraft gross weight is %7.1f pounds.\n", MIN_GROSS); printf(" The maximum aircraft gross weight is %7.1f pounds.\n", MAX_GROSS); printf("\n"); printf("Forward CG Limitations:\n"); printf(" For Aircraft Gross Weight below %7.1f lb:\n", FWD_CG_BRKGW); printf(" FWD CG Limit is %6.2f\" aft of the datum.\n", FWD_CG_MINGW); printf(" For Aircraft Gross Weight between %7.1f lb and %7.1f lb:\n", FWD_CG_BRKGW, MAX_GROSS); printf(" FWD CG Limit moves linearly from %6.2f\" to %6.2f\".\n", FWD_CG_MINGW, FWD_CG_MAXGW); printf("\n"); printf("Aft CG Limitations:\n"); printf(" For Aircraft Gross Weights below %7.1f lb:\n", AFT_CG_BRKGW); printf(" AFT CG Limit is %6.2f\" aft of the datum.\n", AFT_CG_MINGW); printf(" For Aircraft Gross Weights between %7.1f lb and %7.1f lb:\n", AFT_CG_BRKGW, MAX_GROSS); printf(" AFT CG Limit moves linearly from %6.2f\" to %6.2f\".\n", AFT_CG_MINGW, AFT_CG_MAXGW); printf("===============================================================\n"); /* Section 2 - Gather Data for CG Calculation ----------------------------*/ printf("\n"); printf("===============================================================\n"); printf("Data Entry for Weight and Balance Compution:\n"); printf("NOTES:\n"); printf(" 1) Enter all weights in pounds.\n"); printf(" 2) Enter all locations in inches aft of the datum.\n"); printf("\n"); printf("Aircraft Empty Weight:\n"); printf(" Enter the weight: ......"); scanf("%lf", &empty_wt); printf(" Enter the location:....."); scanf("%lf", &empty_cg); printf("\n"); printf("Fuel\n"); printf(" Enter the weight: ......"); scanf("%lf", &fuel_wt); printf(" Enter the location:....."); scanf("%lf", &fuel_cg); printf("\n"); printf("Front Seat Occupants:\n"); printf(" Enter the weight: ......"); scanf("%lf", &frontpax_wt); printf(" Enter the location:....."); scanf("%lf", &frontpax_cg); printf("\n"); printf("Rear Seat Occupants:\n"); printf(" Enter the weight: ......"); scanf("%lf", &rearpax_wt); printf(" Enter the location:....."); scanf("%lf", &rearpax_cg); printf("\n"); printf("Baggage Area Contents:\n"); printf(" Enter the weight: ......"); scanf("%lf", &baggage_wt); printf(" Enter the location:....."); scanf("%lf", &baggage_cg); printf("\n"); printf("Combined Miscellaneous Items:\n"); printf(" Enter the weight: ......"); scanf("%lf", &misc_wt); printf(" Enter the location:....."); scanf("%lf", &misc_cg); printf("===============================================================\n"); /* Section 3 - Compute and output the Loading Table ----------------------*/ /* Total Up the individual item weights */ gross_wt = gross_mom = 0.0; gross_wt += empty_wt; gross_wt += fuel_wt; gross_wt += frontpax_wt; gross_wt += rearpax_wt; gross_wt += baggage_wt; gross_wt += misc_wt; /* Total Up the individual item moments */ gross_mom = 0.0; gross_mom += empty_wt*empty_cg; gross_mom += fuel_wt*fuel_cg; gross_mom += frontpax_wt*frontpax_cg; gross_mom += rearpax_wt*rearpax_cg; gross_mom += baggage_wt*baggage_cg; gross_mom += misc_wt*misc_cg; /* Compute the total CG of all the items */ gross_cg = gross_mom / gross_wt; /* Output the Loading Table */ printf("\n"); printf("===============================================================\n"); printf("AIRCRAFT LOADING TABLE\n"); printf("Aircraft Type: %s\n", AIRCRAFT_TYPE); printf("===============================================================\n"); printf("ITEM WEIGHT (lbs) ARM (in) MOMENT (in-lbs)\n"); printf("Empty Weight %8.1f %7.2f %10.2f\n", empty_wt, empty_cg, empty_wt*empty_cg); printf("Fuel %8.1f %7.2f %10.2f\n", fuel_wt, fuel_cg, fuel_wt*fuel_cg); printf("Front Occupants %8.1f %7.2f %10.2f\n", frontpax_wt, frontpax_cg, frontpax_wt*frontpax_cg); printf("Rear Occupants %8.1f %7.2f %10.2f\n", rearpax_wt, rearpax_cg, rearpax_wt*rearpax_cg); printf("Baggage Area %8.1f %7.2f %10.2f\n", baggage_wt, baggage_cg, baggage_wt*baggage_cg); printf("Miscellaneous %8.1f %7.2f %10.2f\n", misc_wt, misc_cg, misc_wt*misc_cg); printf("===============================================================\n"); printf("TOTAL %7.1f %6.2f %9.2f\n", gross_wt, gross_cg, gross_mom); printf("===============================================================\n"); printf("\n"); /* End of Program --------------------------------------------------------*/ return(0); }