Challenge

Project 3

Mrs.Abinaya Inbamani -TSE

Program code:

#include<stdio.h>//header file
#include <iostream>//header file
using namespace std;
#define size 2//macro definition
#define MAXKM 50000//macro definition
class vehicle//base class declaraton
{ public:

public://access specifier
string make, model,type;//data type declaration
enum TYPE{GAS,ELECTRIC,DIESEL};//enum datatype declaration
int year;//datatype declaration
float odometer;//datatype declaration
virtual void setmake();//virtual function declaration
virtual void putmake();//virtual function declaration
virtual void setmodel();//virtual function declaration
virtual void putmodel();//virtual function declaration
virtual void setyear();//virtual function declaration
virtual void putyear();//virtual function declaration
virtual void setodometer();//virtual function declaration
virtual void putodometer();//virtual function declaration
};

void vehicle::setmake()//scope resolution and derived class declaration
{
cout<<"Enter make of the vehicle"<<endl;//content displayed in the console
cin >> make;//input on the console
}
void vehicle::putmake()
{
cout<<"\t"<<make;//for space
}
void vehicle::setmodel()
{
cout<<"\n Enter model of the vehicle"<<endl;//content displayed in the console
cin >> model;//input on the console
}
void vehicle::putmodel()
{
cout<<"\t"<<model;//for space
}
void vehicle::setyear()
{
cout<<"\n Enter manufactured year of the vehicle"<<endl;//content displayed in the console
cin >> year;//input on the console
}
void vehicle::putyear()
{
cout<<"\t"<<year;//for space
}
void vehicle::setodometer()
{
cout<<"\n Float data speedometer of the vehicle"<<endl;//content displayed in the console
cin >> odometer;//input on the console
}
void vehicle::putodometer()
{
cout<<"\t"<<odometer;//for space
if(odometer>50000)//control statement
cout<<"\n Tyre Rotation to be done "<<endl;//content displayed in the console
else
cout<<" \n Less than 50000 KMS -Tyre rotation can be done in next visit."<<endl;//content displayed in the console
if(odometer < 400)//control statement
cout<<"\n Battery need not be recharged"<<endl;//content displayed in the console
else
cout<<"\n Battery need to be recharged"<<endl;//content displayed in the console
}


void menudisplay()//function declaration
{
cout << " 0. Quit.\n";//content displayed in the console
cout<< " 1. displayservices.\n";//content displayed in the console
cout<< " 2. Add vehicle.\n";//content displayed in the console

}
void displayservices()//function declaration
{
cout<<"\n oil change or replace oil filter, replace air filter"<<endl;//content displayed in the console
cout<<"replace fuel filter, tire rotations, infotainment debug"<<endl;//content displayed in the console
cout<<"replace spark plugs, replace the cabin filter, check the level"<<endl;//content displayed in the console
cout<<" refill clutch fluid"<<endl;//content displayed in the console
cout<<"brake fluid, examine belts, wipers, hoses"<<endl;//content displayed in the console
cout<<"check the tire conditions, check the charging systems, battery"<<endl;//content displayed in the console

}
int main()//main function declaration
{ int user_choice;//datatype declaration
beginning: menudisplay();
cout<<"Enter your choice in no"<<endl;//content displayed in the console
cin >> user_choice;
switch(user_choice)//control statement
{
case 0 :cout <<"Exiting the program ";//content displayed in the console
break ;
case 1 : displayservices();
goto beginning;//control statement
case 2:
vehicle *pv=new vehicle();//pointer calling
pv->setmake();//function calling
pv->setmodel();//function calling
pv->setyear();//function calling
pv->setodometer();//function calling
pv->putmake();//function calling
pv->putmodel();//function calling
pv->putyear();//function calling
pv->putodometer();//function calling

goto beginning;//control statement

}

}

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.