Electrical and Computer Engineering
21 of 24
UAH
CPE 112
Case Study Implementation
•float CargoMoment( /*in*/ int closet,     // Weight in closet
•                   /*in*/ int baggage )   // Weight of baggage
•
•// Computes the total moment arm for cargo loaded into the
•// front closet and aft baggage compartment
•// Precondition:
•//     0 <= closet <= 160  &&  0 <= baggage <= 525
•// Postcondition:
•//     Function value == Cargo moment arm, based on the closet
•//     and baggage parameters
•
•{
•    const float CLOSET_DIST = 182.0;    // Distance to closet
•    const float BAGGAGE_DIST = 386.0;   // Distance to baggage
•    return float(closet) * CLOSET_DIST +
•           float(baggage) * BAGGAGE_DIST;
•}