Did I do something wrong?
<p>When I entered -1, it didn't stop. :\ Also, when I enter "12.8" as "Enter the gallons used" and "287" for the miles driven. It gave me "22.4219" as the average but I want it to be "22.421875". So what did I do wrong here? Here's my code:</p>

<pre><code>// 2.16: Write a program that will input the miles driven and gallons used for each tankful
// Find the overall agerage miles/gallon

#include &lt;iostream&gt;

using namespace std;

#include &lt;iomanip&gt;

int main()
{
    int miles;
    double gallon,total,Overall,overMile,overGallon;

    total = 0;
    overMile = 0;
    overGallon = 0;

    while ( gallon != -1 )
        {
            overMile = overMile + miles;
            overGallon = overGallon + gallon;

            cout &lt;&lt; "Enter the gallons used ( -1 to end ): ";
            cin &gt;&gt; gallon;
            cout &lt;&lt; "Enter the miles driven: ";
            cin &gt;&gt; miles;

            total = (double) miles / gallon;
            cout &lt;&lt; "The miles/gallons for this tank was: " &lt;&lt; total &lt;&lt; endl;
            cout &lt;&lt; setiosflags( ios::fixed | ios::showpoint ) &lt;&lt; setprecision( 6 );

            cout &lt;&lt; endl;
        }

    Overall = (double) overMile / overGallon;
        cout &lt;&lt; "The overall average miles/gallon was " &lt;&lt; Overall &lt;&lt; endl;
        cout &lt;&lt; setiosflags( ios::fixed | ios::showpoint ) &lt;&lt; setprecision( 5 );

    return 0;
}
</code></pre>
