Car Instrument Simulator

I got an error on line 44: fatal error: FuelGauge.h: No such file or directory
How can I fix this error?
Also, I would really appreciate if you tell me other errors that you've found.
Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include <cstdlib>
#include <string>

// FuelGauge.h
using namespace std;

#ifndef FUELGAUGE_H
#define FUELGAUGE_H

class FuelGauge
{
private:
    int currentAmountOfFuel;
public:
    FuelGauge(int gallons)
    {
        currentAmountOfFuel = gallons;
    }

	FuelGauge();

	int getCurrentAmountOfFuel() const
	{
		return currentAmountOfFuel;
	}

	void incrementFuelTank()
	{
		if (currentAmountOfFuel< 15)
			currentAmountOfFuel++;
	}

	void decrementFuelTank()
	{
        if (currentAmountOfFuel > 0)
			currentAmountOfFuel--;
	}
};

#endif

// Odometer.h
#include "FuelGauge.h"
using namespace std;

#ifndef ODOMETER_H
#define ODOMTER_H

class Odometer
{
private:
	int currentMileage;
	FuelGauge *fuelG;
public:
	Odometer(int miles, FuelGauge *f)
	{
		currentMileage = miles;
		fuelG = f;
	}

	int getCurrentMileage()
	{
		return currentMileage;
	}
	void incrementcurrentMileage()
	{
		if (currentMileage < 999999)
			currentMileage++;
		if (currentMileage == 999999)
			currentMileage = 0;
	}
	void decrementcurrentMileage()
	{
		if (currentMileage > 24)
			currentMileage--;
	}
};

#endif

// main
#include "FuelGauge.h"
#include "Odometer.h"
using namespace std;

int main()
{
	FuelGauge fuel(x);
	Odometer odm(0, &fuel);

	for (int i = 0; i < 15; i++)
		fuel.incrementFuelTank();

	while (fuel.getCurrentAmountOfFuel() > 0)
	{
		odm.incrementcurrentMileage();
		cout << "Current mileage is " << odm.getCurrentMileage() << endl;
		cout << "Current fuel level is" << fuel.getCurrentAmountOfFuel() << " gallons" << endl;
	}

	return 0;
}
Hi There

file you are referring is header file, #include "FuelGauge.h" this file should be located where is your main program .cpp located.

Topic archived. No new replies allowed.