/************************************************************************ *Jason Calcagno *AP/IB Computer Science *Functions Part Deux *INput: Number of crew members, number of passengers, weight of closet contents, baggage weight, fuel in gallons *Output: total wight, center of gravity *December 13, 2002 ************************************************************************/ #include int cargoMoment (int baggage, closet); int crewMoment (int crew); int passengerMoment (int passengers); int fuelMoment (int fuel); int main () { int crew, passengers; int emptyWeight, baggage, closet, fuel, jtotalWeight, tWeight, centerOfGravity; cout<< "What is the total weight of the plane? "; cin >> emptyWeight; cout<< "What is the total weight of the baggage in the baggage hold? "; cin >> baggage; cout<< "What is the total weight of the baggage in the closet? "; cin>> closet; cout<< "How many passengers are on the plane? "; cin>> passengers; cout<< "How many crew members are on the flight? "; cin>> crew; cout<< "How many gallons of fuel are in the tank? "; cin>> fuel; jtotalWeight == emptyWeight + (crew + passengers) * 170 + baggage + closet + fuel * 6.7; centerOfGravity = ((3153953 + crewMoment + passengerMoment + cargoMoment + fuelMoment)/jtotalWeight); return 0; } int CrewMoment (int crew) { return (crew * 170 * 143); } int passengerMoment { if (passengers == 1) return 170 * 265; if (passengers == 2) return (2 * 170) * 265; if (passengers == 3) return ((2 * 170) * 265)+(170*219); if (passengers == 4) return ((2 * 170) * 265)+((2*170)*219); if (passengers == 5) return (90100)+((2*170)*219)+ (170 * 295); if (passengers == 6) return (90100)+((2*170)*219)+ ((2*170) * 295); if (passengers == 7) return (90100)+((2*170)*219)+ ((2*170) * 295)+(170*341); if (passengers == 8) return (90100)+((2*170)*219)+((2*170) * 295)+((2*170)*341); } int CargoMoment (int baggage, closet) { return ((closet * 182)+(baggage * 386)) } int FuelMoment (int fuel) { if (fuel >= 0 && fuel <= 59) return (314.6 * fuel); if (fuel >= 60 && fuel <= 360) return (305.8 * fuel); if (fuel >= 361 && fuel <= 520) return (303.0 * fuel); if (fuel >= 521 && fuel <= 565) return (323.0 * fuel); }