Hi I am trying to create a loop that increments a cars mileage while the fuel decreases by 1 gallon for every 24 miles.

Instructions: To be able to work with the FuelGauge Object. It should decrease the FuelGauge object's current amount of fuel by 1 gallon for every 24 miles traveled. (The car's fuel economy is 24 miles per gallon.)

Here is my main of my program:

#include "FuelGauge.h"
#include "Odometer.h"
#include <iostream>

using namespace std;

int main()
{
    FuelGauge fuel(10);
    Odometer miles(250, &fuel);

    for (int count = 0; count < 15; count++)
    {
        miles.incrementMiles();// plainly increments the miles
        fuel.decrementGal(); // decrements the fuel by 1 gallon when (gallons > 0)
        fuel.incrementGal(); // increments the fuel by 1 gallon when (gallons < 15)

        cout << "Amount of fuel: " << fuel.getGal() << endl;
        cout << "Current mileage: " << miles.getMilegage() << endl;
        cout << endl;
    }

    return 0;
} 

Any help would be appreciated, I've been stuck for an hour trying different things.

Can not determine a problem without miles and fuel classes shown.

.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.