Project 3
#include<iostream>
using namespace std;
#define size 2
#define MAXKM 50000//declaring reading to 50000km
class vehicle//declaring class
{
public:
string make,model,type;//string declaration
enum TYPE{GAS,ELECTRIC,DIESEL};//declaring enum data types
int year;//integer for year
float odometer;//odometer reading
virtual void setmake();//sub functions calling inside class
virtual void putmake();
virtual void setmodel();
virtual void putmodel();
virtual void setyear();
virtual void putyear();
virtual void setodometer();
virtual void putodometer();
};
void vehicle::setmake(){//scope resolution to visual outside class
cout<<"Enter the make of vehicle"<<endl;// printing output
cin>>make;//user input
}
void vehicle::putmake(){
cout<<"\t"<<make;// tab space
}
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)//applying condition to change tyre rotation
cout<<"\n Change the tyre rotation"<<endl;
else
cout<<"\n Less than 50000KMS-Change tyre on next visit"<<endl;
}
void menudisplay()//function for menu
{
cout<<"0.Quit.\n";
cout<<"1.Display services.\n";
cout<<"2.Add vehicle. \n";
}
void displayservices()//displaying services
{
cout<<"\n1.Oil change or replace oil filter, replace air filter"<<endl;
cout<<"2.Replace fuel filter, tire rotations, infotainment system debug"<<endl;
cout<<"3.Replace spark plugs, replace the cabin or a/c filter, check the level"<<endl;
cout<<"4.Refill clutch fluid"<<endl;
cout<<"5.Brake fluid, examine belts, wipers, hoses"<<endl;
cout<<"6.Check the tire conditions, check the charging systems and battery."<<endl;
}
int main()
{
int user_choice;
beginning: menudisplay();
cout<<"Enter your choice in no"<<endl;
cin>>user_choice;
switch(user_choice)// switch is used to switch between 3 menus
{
case 0: cout<<"Exiting the program";
//break;
case 1:displayservices();
goto beginning;
case 2:
vehicle *pv=new vehicle();// calling pointer to enter new vehicle data
pv->setmake();
pv->setmodel();
pv->setyear();
pv->setodometer();
pv->putmake();
pv->putmodel();
pv->putyear();
pv->putodometer();
goto beginning;//acts as while loop
}
}
output:
0.Quit.
1.Display services.
2.Add vehicle.
Enter your choice in no
1
1.Oil change or replace oil filter, replace air filter
2.Replace fuel filter, tire rotations, infotainment system debug
3.Replace spark plugs, replace the cabin or a/c filter, check the level
4.Refill clutch fluid
5.Brake fluid, examine belts, wipers, hoses
6.Check the tire conditions, check the charging systems and battery.
0.Quit.
1.Display services.
2.Add vehicle.
Enter your choice in no
2
Enter the make of vehicle
4
Enter model of the vehicle
13
Enter manufactured year of the vehicle
12
Float data speedometer of the vehicle
1212
4 13 12 1212
Less than 50000KMS-Change tyre on next visit
0.Quit.
1.Display services.
2.Add vehicle.
Enter your choice in no
0
Exiting the program
1.Oil change or replace oil filter, replace air filter
2.Replace fuel filter, tire rotations, infotainment system debug
3.Replace spark plugs, replace the cabin or a/c filter, check the level
4.Refill clutch fluid
5.Brake fluid, examine belts, wipers, hoses
6.Check the tire conditions, check the charging systems and battery.
0.Quit.
1.Display services.
2.Add vehicle.
Enter your choice in no
