0

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.

2
Contributors
2
Replies
22
Views
4 Years
Discussion Span
Last Post by Rachel Roxx
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.