Challenge

Project 3

project 3  Ans:

#include
#include

using namespace std;
class Maintenance //abstract class
{
public:
string list={"Tata Creta Ertiga"};

void List__inventory(){

cout<<"list inventory"<}
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"< cout<<"enter the car name need to be added"<cin>>newcar;
cout<<"enter the car newmake to be added"<cin>>newmake;
cout<<"enter the newmodel need to be added"<cin>>newmodel;
cout<<"enter the newyear to be added"<cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "< }else if (type==1)
{
cout<<"Give the following details of the entered Diesel type"< cout<<"enter the car name need to be added"< cin>>newcar;
cout<<"enter the car newmake to be added"< cin>>newmake;
cout<<"enter the newmodel need to be added"< cin>>newmodel;
cout<<"enter the newyear to be added"< cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "< }
else if (type==2)
{
cout<<"Give the following details of the entered Electric type"< cout<<"enter the car name need to be added"< cin>>newcar;
cout<<"enter the car newmake to be added"< cin>>newmake;
cout<<"enter the newmodel need to be added"< cin>>newmodel;
cout<<"enter the newyear to be added"< cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "< }

}while(type<0||type>2);
}
void Update_Vehicle(){
cout<<"updatelist"<}
void Remove_Vehicle(){

cout<<"remove the vehicle from the inventory list"< string word;
cin>>word;
int pos=list.find(word);
if(pos!=string::npos)
{
list.erase(pos,word.length()+1);
cout<<"The updated list"<<" "< }
else
cout<<"The vehicle is not found"<}
void Tire_Rotation(){
int odometer;

cout<<"Enter the odometer reading"< cin>>odometer;//40000
int remainder = odometer-50000;

if (remainder>0)
cout<<"change tire"<

else
{
cout<<"you are good to go"<

}
}
void check_power(){
int distance;
cout<<"Enter the distance"< cin>>distance;
if(distance>=400000)
cout<<"advise battery to be recharged"< else
{
cout<<"your vehicle is good to go"< }

}

void Oil_Change(){
int distance;
cout<<"Enter the distance"< cin>>distance;
if(distance>=4000)
cout<<"car requires oil change "< else
{
cout<<"your vehicle is good to go"< }

}

};
int main()
{
int n;
//vehicle v;
Maintenance M;

cout<<"The Menu is follows";
cout<<"0.Quit"< "3.update Vechile"< "6.Oil Change"<

beginning:
cout<<"Enter the choice you want";

cin>>n;

switch(n)
{
case 0:
cout<<"You have chosen option 0"< //exit(0);
break;

case 1:
cout<<"you have chosen option 1 "< M.List__inventory();
goto beginning;

case 2:
cout<<"you have chosen option 2 "< M.Add_Vehicle();
goto beginning;
case 3:
cout<<"You have chosen option 3"< M.Update_Vehicle();
goto beginning;
case 4:
cout<<"you have chosen option 4"< M.Remove_Vehicle();
goto beginning;
case 5:
cout<<"You have chosen option 5"< M.Tire_Rotation();
goto beginning;
case 6:
cout<<"You have chosen option 6"< M.Oil_Change();
goto beginning;
case 7:
cout<<"You have chosen option 7"< 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 want 1
you have chosen option 1
list inventoryTata Creta Ertiga
Enter the choice you want 2
you have chosen option 2
Enter 0: GAS
1.DIESEL
2.ELECTRIC 1
Give the following details of the entered Diesel type
enter the car name need to be added
maruti
enter the car newmake to be added
a5
enter the newmodel need to be added
benz
enter the newyear to be added
2023
addedlist maruti
make of the car maruti
Enter the choice you want 3
You have chosen option 3
updatelistTata Creta Ertiga maruti
Enter the choice you want 4
you have chosen option 4
remove the vehicle from the inventory listTata Creta Ertiga maruti
creta
The vehicle is not found
Enter the choice you want 5
You have chosen option 5
Enter the odometer reading
400
you are good to go
Enter the choice you want 6
You have chosen option 6
Enter the distance
5000
car requires oil change Tata Creta Ertiga maruti
Enter the choice you want 7
You have chosen option 7
Enter the distance
1000
your vehicle is good to go
Enter the choice you want

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.