Counter not working?
<p>I am writing a program for a homework assignment that calculates rental car rates based on make, days rented and miles driven. Overall the program works except, when the user is prompted for the number of cars to be calculated, the program continues to prompt the user for input after the number has been exceeded. Also, the formatting for the miles is correct for the first vehicle entered but changes for subsequent entries.</p>

<p>Any help with these two issues would be greatly appreciated!</p>

<p>Code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;iomanip&gt;
#include &lt;cmath&gt;

using namespace std;

int main()
{
    // Change the console's background color.
    system ("color F0");

    // Declare the variables.
    char carType;
    string brand, f("Ford"), c("Chevrolet");
    int counter = 0, cars = 0;
    double days, miles, cost_Day, cost_Miles, day_Total;

    cout &lt;&lt; "Enter the number of cars you wish to enter: ";
    cin &gt;&gt; cars;
    cin.ignore();

    while (counter &lt;= cars)
    {

        cout &lt;&lt; "Enter the car type (F or C): ";
        cin &gt;&gt; carType;
        cin.ignore();
        cout &lt;&lt; "Enter the number of days rented: ";
        cin &gt;&gt; days;
        cin.ignore();
        cout &lt;&lt; "Enter the number of miles driven: ";
        cin &gt;&gt; miles;
        cin.ignore();


        if (carType == 'F' || carType == 'f')
        {
            cost_Day = days * 40;
            cost_Miles = miles * .35;
            day_Total = cost_Miles + cost_Day;
            brand = f;
        }
        else
        {
            cost_Day = days * 35;
            cost_Miles = miles * .29;
            day_Total = cost_Miles + cost_Day;
            brand = c;
        }

        cout &lt;&lt; "\nCar            Days   Miles        Cost\n";
        cout &lt;&lt; left &lt;&lt; setw(12) &lt;&lt; brand &lt;&lt; right &lt;&lt; setw(6) &lt;&lt; days &lt;&lt; right &lt;&lt; setw(8) &lt;&lt; miles 
        &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision (2) &lt;&lt; setw(8) &lt;&lt; right &lt;&lt; "$" &lt;&lt; day_Total &lt;&lt; "\n\n";
        counter++;
    }


        system ("pause");
}
</code></pre>
