Project 3
PROJECT 3 CODE:
#include<iostream>
#include<string>
using namespace std;
class Maintenance
{
public:
string list={"maruthi creta breeza"};
void List__inventory(){
cout<<"list inventory"<<list<<endl;
}
void Add_Vehicle(){
string newcar, newmake, newmodel;
int newyear;
//string list;
int type=-1;
do {
cout<<"Enter 0: GAS\n1.DIESEL\n2.ELECTRIC";
cin>>type;
if(type==0)
{
cout<<"Give the following details of the entered GAS type"<<endl;
cout<<"enter the car name need to be added"<<endl;
cin>>newcar;
cout<<"enter the car newmake to be added"<<endl;
cin>>newmake;
cout<<"enter the newmodel need to be added"<<endl;
cin>>newmodel;
cout<<"enter the newyear to be added"<<endl;
cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "<<newcar<<endl<<"make of the car"<<" "<<newcar<<endl;
}else if (type==1)
{
cout<<"Give the following details of the entered Diesel type"<<endl;
cout<<"enter the car name need to be added"<<endl;
cin>>newcar;
cout<<"enter the car newmake to be added"<<endl;
cin>>newmake;
cout<<"enter the newmodel need to be added"<<endl;
cin>>newmodel;
cout<<"enter the newyear to be added"<<endl;
cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "<<newcar<<endl<<"make of the car"<<" "<<newcar<<endl;
}
else if (type==2)
{
cout<<"Give the following details of the entered Electric type"<<endl;
cout<<"enter the car name need to be added"<<endl;
cin>>newcar;
cout<<"enter the car newmake to be added"<<endl;
cin>>newmake;
cout<<"enter the newmodel need to be added"<<endl;
cin>>newmodel;
cout<<"enter the newyear to be added"<<endl;
cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "<<newcar<<endl<<"make of the car"<<" "<<newcar<<endl;
}
}while(type<0||type>2);
}
void Update_Vehicle(){
cout<<"updatelist"<<list<<endl;
}
void Remove_Vehicle(){
cout<<"remove the vehicle from the inventory list"<<list<<endl;
string word;
cin>>word;
int pos=list.find(word);
if(pos!=string::npos)
{
list.erase(pos,word.length()+1);
cout<<"The updated list"<<" "<<list<<endl;
}
else
cout<<"The vehicle is not found"<<endl;
}
void Tire_Rotation(){
int odometer;
cout<<"Enter the odometer reading"<<endl;
cin>>odometer;//40000
int remainder = odometer-50000;
if (remainder>0)
cout<<"change tire"<<endl;
else
{
cout<<"you are good to go"<<endl;
}
}
void check_power(){
int distance;
cout<<"Enter the distance"<<endl;
cin>>distance;
if(distance>=400000)
cout<<"advise battery to be recharged"<<endl;
else
{
cout<<"your vehicle is good to go"<<endl;
}
}
void Oil_Change(){
int distance;
cout<<"Enter the distance"<<endl;
cin>>distance;
if(distance>=4000)
cout<<"car requires oil change "<<list<<endl;
else
{
cout<<"your vehicle is good to go"<<endl;
}
}
};
int main()
{
int n;
//vehicle v;
Maintenance M;
cout<<"The Menu is follows";
cout<<"0.Quit"<<endl<<"1.List inventory"<<endl<<"2.Add Vehicle"<<
"3.update Vechile"<<endl<<"remove Vehicle"<<endl<<"5.Tire Rotation"<<endl<<
"6.Oil Change"<<endl<<"7.Recharge"<<endl;
beginning:
cout<<"Enter the choice you want";
cin>>n;
switch(n)
{
case 0:
cout<<"You have chosen option 0"<<endl;
//exit(0);
break;
case 1:
cout<<"you have chosen option 1 "<<endl;
M.List__inventory();
goto beginning;
case 2:
cout<<"you have chosen option 2 "<<endl;
M.Add_Vehicle();
goto beginning;
case 3:
cout<<"You have chosen option 3"<<endl;
M.Update_Vehicle();
goto beginning;
case 4:
cout<<"you have chosen option 4"<<endl;
M.Remove_Vehicle();
goto beginning;
case 5:
cout<<"You have chosen option 5"<<endl;
M.Tire_Rotation();
goto beginning;
case 6:
cout<<"You have chosen option 6"<<endl;
M.Oil_Change();
goto beginning;
case 7:
cout<<"You have chosen option 7"<<endl;
M.check_power();
goto beginning;
}
return 0;
}
OUTPUT:
The Menu is follows0.Quit
1.List inventory
2.Add Vehicle3.update Vechile
remove Vehicle
5.Tire Rotation
6.Oil Change
7.Recharge
Enter the choice you want1
you have chosen option 1
list inventorymaruthi creta breeza
Enter the choice you want2
you have chosen option 2
Enter 0: GAS
1.DIESEL
2.ELECTRIC1
Give the following details of the entered Diesel type
enter the car name need to be added
toyoto
enter the car newmake to be added
make1
enter the newmodel need to be added
v5
enter the newyear to be added
2012
addedlist toyoto
make of the car toyoto
Enter the choice you want3
You have chosen option 3
updatelistmaruthi creta breeza toyoto
Enter the choice you want4
you have chosen option 4
remove the vehicle from the inventory listmaruthi creta breeza toyoto
creta
The updated list maruthi breeza toyoto
Enter the choice you want5
You have chosen option 5
Enter the odometer reading
400
you are good to go
Enter the choice you want6
You have chosen option 6
Enter the distance
3000
your vehicle is good to go
Enter the choice you want7
You have chosen option 7
Enter the distance
5000
your vehicle is good to go
Enter the choice you want6
You have chosen option 6
Enter the distance
5000
car requires oil change maruthi breeza toyoto
Enter the choice you want6
You have chosen option 6
Enter the distance
1000
your vehicle is good to go
Enter the choice you want6
You have chosen option 6
Enter the distance
6000
car requires oil change maruthi breeza toyoto
Enter the choice you want