Electrical and Computer Engineering
22 of 24
UAH
CPE 112
Case Study Implementation
•float FuelMoment( /* in */ int fuel )    // Fuel in gallons
•{
•    float fuelWt;           // Weight of fuel in pounds
•    float fuelDistance;     // Distance from front of plane
•
•    fuelWt = float(fuel) * LBS_PER_GAL;
•    if (fuel < 60)
•        fuelDistance = float(fuel) * 314.6;
•    else if (fuel < 361)
•        fuelDistance = 305.8 + (-0.01233 * float(fuel - 60));
•    else if (fuel < 521)
•        fuelDistance = 303.0 + ( 0.12500 * float(fuel - 361));
•    else
•        fuelDistance = 323.0 + (-0.04444 * float(fuel - 521));
•    return fuelDistance * fuelWt;
•}