Project 3
Abinaya batch
Questian Ans:-
#include <iostream>
using namespace std;
#define size 2
#define MAXKM 50000
class vehicle
{
public:
string make, model, type;
enum TYPE {GAS, ELECTRIC, DIESEL};
int year;
float odometer; virtual void setmake();
virtual void putmake();
virtual void setmodel(); virtual void putmodel();
virtual void setyear();
virtual void putyear(); virtual void setodometer(); virtual void putodometer();
};
void vehicle::setmake()
{
cout<<"Enter make of the vehicle"<<endl;
cin >> make;
}
void vehicle::putmake()
{
cout<<"\t"<<make;
}
void vehicle::setmodel()
{
cout<<"\n Enter model of the vehicle"<<endl;
cin >> model;
}
void vehicle::putmodel()
{
cout<<"\t"<<model;
}
void vehicle::setyear()
{
cout<<"\n Enter manufactured year of the vehicle"<<endl;
cin>> year;
}
void vehicle::putyear()
{
cout <<"\t"<<year;
}
void vehicle::setodometer()
{
cout<<"\n Float data speedometer of the vehicle"<<endl;
cin >> odometer;
}
void vehicle::putodometer()
{
cout<<"\t"<<odometer;
if (odometer>50000)
cout<<"\n Tyre Rotation to be done "<<endl;
else
cout<<" \n Less than seeeel KMS -Tyre rotation can be done in next visit."<<endl;
}
void menudisplay()
{
cout << "0. Quit.\n";
cout<<" 1. displayservices.\n";
cout<<" 2. Add vehicle. \n";
}
void displayservices()
{
cout<<"\n oil change or replace oil filter, replace air filter"<<endl;
cout<<"replace fuel filter, tire rotations, infotainment debug"<<endl;
cout<<"replace spark plugs, replace the cabin filter, check the level"<<endl;
cout<<" refill clutch fluid"<<endl;
cout<<"brake fluid, examine belts, wipers, hoses"<<endl;
cout<<"check the tire conditions, check the charging systems, battery"<<endl;
}
int main()
{
int user_choice;
beginning: menudisplay();
cout<<"Enter your choice in no"<<endl;
cin >> user_choice;
switch(user_choice)
{
case 0:cout <<"Exiting the program";
break;
case 1: displayservices();
goto beginning;
case 2:
vehicle *pv=new vehicle();
pv->setmake();
pv->setmodel(); pv->setyear();
pv->setodometer();
pv->putmake();
pv->putmodel();
pv->putyear();
pv->putodometer();
goto beginning;
}
}
Output
0. Quit.
1. displayservices.
2. Add vehicle.
Enter your choice in no
2
Enter make of the vehicle
15
Enter model of the vehicle
x9
Enter manufactured year of the vehicle
2022
Float data speedometer of the vehicle
65214
15 x9 2022 65214
Tyre Rotation to be done
0. Quit.
1. displayservices.
2. Add vehicle.
Enter your choice in no
1
oil change or replace oil filter, replace air filter
replace fuel filter, tire rotations, infotainment debug
replace spark plugs, replace the cabin filter, check the level
refill clutch fluid
brake fluid, examine belts, wipers, hoses
check the tire conditions, check the charging systems, battery
0. Quit.
1. displayservices.
2. Add vehicle.
Enter your choice in no
2
Enter make of the vehicle