//******************************************************************
// FuelMomentDriver program
// This program provides an environment for testing the
// FuelMoment function in isolation from the Starship program
//******************************************************************
#include <iostream>

using namespace std;

const float LBS_PER_GAL = 6.7;

float FuelMoment( int );

int main()
{
    int testVal;    // Test value for fuel in gallons

    cout << "Fuel moment for gallons from 10 through 565"
         << " in steps of 15:" << endl;
    testVal = 10;
    while (testVal <= 565)
    {
        cout << FuelMoment(testVal) << endl;
        testVal = testVal + 15;
    }
    return 0;
}

//******************************************************************

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;
}
