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 newmake to be added"<
cout<<"enter the newmodel need to be added"<
cout<<"enter the newyear to be added"<
list= list+" "+newcar;
cout<<"addedlist"<<" "<
{
cout<<"Give the following details of the entered Diesel type"<
cout<<"enter the car newmake to be added"<
cout<<"enter the newmodel need to be added"<
cout<<"enter the newyear to be added"<
list= list+" "+newcar;
cout<<"addedlist"<<" "<
else if (type==2)
{
cout<<"Give the following details of the entered Electric type"<
cout<<"enter the car newmake to be added"<
cout<<"enter the newmodel need to be added"<
cout<<"enter the newyear to be added"<
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"<
int remainder = odometer-50000;
if (remainder>0) else } } void Oil_Change(){ } }; cout<<"The Menu is follows"; beginning: cin>>n; switch(n) case 1: case 2: } Output: The Menu is follows0.Quit
cout<<"change tire"<
{
cout<<"you are good to go"<
}
void check_power(){
int distance;
cout<<"Enter the distance"<
if(distance>=400000)
cout<<"advise battery to be recharged"<
{
cout<<"your vehicle is good to go"<
int distance;
cout<<"Enter the 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<<"0.Quit"<
cout<<"Enter the choice you want";
{
case 0:
cout<<"You have chosen option 0"<
break;
cout<<"you have chosen option 1 "<
goto beginning;
cout<<"you have chosen option 2 "<
goto beginning;
case 3:
cout<<"You have chosen option 3"<
goto beginning;
case 4:
cout<<"you have chosen option 4"<
goto beginning;
case 5:
cout<<"You have chosen option 5"<
goto beginning;
case 6:
cout<<"You have chosen option 6"<
goto beginning;
case 7:
cout<<"You have chosen option 7"<
goto beginning;
}
return 0;
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