Challenge

Project 3

PROJECT 3

CODE

vehicle.h

#ifndef vehicle_H_
#define vehicle_H_

//preprocessor directive
#include <iostream>
using namespace std;

#define size 2 //macros
#define MAXKM 50000

class vehicle //class creation
{

public:
string make, model,type;

enum TYPE //defining an enumuration
{GAS,ELECTRIC,DIESEL};
int year;
float odometer;

//fuction declarations
virtual void setmake();
virtual void putmake();
virtual void setmodel();
virtual void putmodel();
virtual void setyear();
virtual void putyear();
virtual void setodometer();
virtual void putodometer();
};

#endif

main.cpp

#include"vehicle.h"

void menudisplay() //menu
{
cout<<"\n\n0. Quit.\n";
cout<<"1. Display Services.\n";
cout<<"2. Add Vehicle.\n";

}
void displayservices() //function to Display Services offered
{
cout<<"\n a)Oil-change or Replace Oil filter\t\tb)Replace Air Filter";
cout<<"\n c)Replace Fuel Filter\t\td)Tire rotations\t\te)Infotainment Debug";
cout<<"\n f)Replace Spark Plugs\t\tg)Replace the Cabin Filter\t\th)Check the Level";
cout<<"\n i)Refill Clutch Fluid";
cout<<"\n j)Rake Fluid\t\tk)Examine Belts\t\tl)Wipers\t\tm)Hoses";
cout<<"\n n)Check the Tire Conditions\t\to)Check the Charging Systems\t\tp)Battery"<<endl;

}

int main() //main function
{
int user_choice;
beginning: menudisplay(); //function call
cout<<"\nEnter your choice in no"<<endl;
cin >> user_choice;
switch(user_choice)
{
case 0 :
cout <<"\nExiting the program ";
break ;
case 1 :
displayservices();
goto beginning; //goto line 34
case 2:
vehicle *pv=new vehicle();
//calling function using pointer
pv->setmake();
pv->setmodel();
pv->setyear();
pv->setodometer();
pv->putmake();
pv->putmodel();
pv->putyear();
pv->putodometer();

goto beginning;

}

}

vehicle.cpp

#include"vehicle.h"

//function definitions

void vehicle::setmake()
{
cout<<"Enter make of the vehicle: "<<endl;
cin>>make;
}

void vehicle::putmake()
{
cout<<"\t"<<make;
}
void vehicle::setmodel()
{
cout<<"\nEnter model of the vehicle: "<<endl;
cin>>model;
}

void vehicle::putmodel()
{
cout<<"\t"<<model;
}

void vehicle::setyear()
{
cout<<"\nEnter manufactured year of the vehicle: "<<endl;
cin>>year;
}

void vehicle::putyear()
{
cout<<"\t"<<year;
}

void vehicle::setodometer()
{
cout<<"\nFloat data speedometer of the vehicle: "<<endl;
cin >> odometer;
}

void vehicle::putodometer()
{
cout<<"\t"<<odometer;
if(odometer>50000)
cout<<"\nTyre Rotation to be done "<<endl;
else
cout<<"\nLess than 50000 KMS -Tyre rotation can be done in next visit."<<endl;
if(odometer < 400)
cout<<"\nBattery need not be recharged"<<endl;
else
cout<<"\nBattery need to be recharged"<<endl;
}

OUTPUT

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.