Challenge

Project 3

automobile.cpp

#include"automobile.h"
#include
using namespace std;
void vehicle::setmake() //accesing setmake from class vehicle
{
cout<<"Enter make of the vehicle"<<endl; //user input of make
cin>>make;
}
void vehicle ::putmake() //accesing putmake from class vehicle
{
cout<<"\t"<<make;
}
void vehicle ::setmodel() //accesing setmodel from class vehicle
{
cout<<"Enter model of the vehicle"<<endl;
cin>>model;
}
void vehicle ::putmodel() //accesing putmodel from class vehicle
{
cout<<"\t"<<model;
}
void vehicle ::setyear() //accesing setyear from class vehicle
{
cout<<"Enter the year of Manufactured"<<endl;
cin>>year;
}
void vehicle ::putyear() //accesing putmodel from class vehicle
{
cout<<"\t"<<year;
}
void vehicle :: setodometer() //accesing setodometer from class vehicle
{
cout<<"Enter the speedometer value"<<endl;
cin>>odometer;
}
void vehicle :: putodometer() //accesing putmodel from class vehicle
{
cout<<"\t"<<odometer<<endl;
if(odometer>50000) //checking condition to be changed a tire or not
cout<<"Tyre rotation to be done"<<endl;
else
cout<< "Tyre rotation should be done in Next Visit"<<endl;
if(odometer<400) //checking condition for changing the battery
cout<<"Battery need not to be Recharged"<<endl;
else
cout<<"Battery need to be Recharged"<<endl;
if(odometer>3000)
cout<<"you need to change oil"<<endl;
else
cout<<"no need to change oil";


}

automobile.h

//headerfile creation*/
#ifndef AUTOMOBILE_H_
#define AUTOMOBILE_H_
#include
using namespace std;

#define MAXKM 50000; //maxkm fixed
class vehicle //creating a class
{
public:
string make,model,type; //variables as string datatype
int year;
float odometer;
enum type{GAS,ELECTRICC,DIESEL}; //selection of car to be selected
/*virtual function 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 /* AUTOMOBILE_H_ */

main.cpp

//driver code
#include"automobile.h"
#include
void menudisplay() //display menu
{
cout<<"0.Quit\n"<<"1.displayservices\n"<<"2.add vehicle\n"<<endl;
}
void displayservices() //maintanance services
{
cout<<"oil change or replace oil filter or replace air filters"<<endl;
cout<<"replace fuel filter,tire rotation,infotainment debug"<<endl;
cout<<"replace spark plugs,replace the cabin filter,check the level"<<endl;
cout<<"refill clutch fluid"<<endl;
cout<<"brake fluids,examine belts,wiper hoses"<<endl;
cout<<"check the tyre conditions,check the charging systems,battery"<<endl;
}
int main() //main fun
{
int user_choice; //variable
beginning:menudisplay();
cout<<"enter your choice"<<endl;
cin>>user_choice;
switch(user_choice)
{
case 1:
cout<<"exiting the program";
case 2:
displayservices(); //calling fun
goto beginning;
case 3:
vehicle *pv=new vehicle(); //virtual fun class object point to reference of new class
pv->setmake(); //calling finctions through member access
pv->setmodel();
pv->setyear();
pv->setodometer();
pv->putmake();
pv->putmodel();
pv->putyear();
pv->putodometer();
goto beginning;
}


}

makefile

all main.cpp automobile.h automobile.c
gcc main.cpp automobile.h automobile.c -o make -I.

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.