a car is a vehicle that we use on daily basis to commute from one place to another. some of its main operations that makes it usable are:start,drive,stop,fill tank,and service. before we can drive the car we need to start it, we then drive it for a a certain distance and stop.
the car consumes petrol, engine oil, water and many other consumables while it is operating. therefore, we need to go to the petrol station to replenish fuel, and the more we drive the more fuel is consumed. periodically we need to service the car to replenish water and engine oil levels.
it is required from you to develop a data type for a car that has the main functions to start, drive, stope, fill tank, and service. the data members must at least include fuel, engine oil, and water. write a menu driven program that uses your car class to demonstrate its functionality
and this is my answer (please correct thim and send it to my email)
and if you can explain why it have many errores or in the site
lass Car {
private:
float water;
float fuel;
float oil;
int engine;
public:
Car() {
water=0.0; fuel-0.0;
oil=0.0; engine=0;
}
void set_water(float w)
{
water=w;
}
void set_fuel(float f)
{
fuel=f;
}
void set_oil(float o)
{
oil=o;
}
void set_engine(int e)
{
engine=e;
}
float getwater()
{return water;}
float getoil()
{return oil;}
int getengine()
{ return engine;}
float getfuel()
{ return fuel;}
};
void start()
{
cout<<"enter 1 for on/0 for off\n";
cin>>engine;
if(engine=1)
cout<<"engine started\n";
}
void drive()
{
float w1,f1,o1;
float distance;
w1=distance*1;
o1=distance*1;
f1=distance*1;
cout<<"distance=";
cin>>distance;
if(f1>fuel)
cout>>"go to petrol station\n";
if(o1>oil)
cout>>"there no\n ";
oil=oil-o1;
water=water-w1;
fuel=fuel-f1;
}
void filltank()
{
set_fuel(100);
}
void service()
{
set_oil(100);
set_water(100);
}
void stope()
{
engine=0;
cout<<"good bye\n";
}
void main()
{
int choose;
cout<<"please choose one of these:\n 1 to start\n 2 to drive\n 3 to stop\n 4 to fill tank\n 5 to service\n 6 to exit\n";
cin>>choose;
switch(choose)
{
case 1:
start(); break;
case 2:
drive(); break;
case 3:
stope(); break;
case 4:
filltank(); break;
case 5:
service(); break;
case 6:
cout<<"thanks\n";
default:
cout<<"errore\m";
}
}