Challenge

Project 3

GUIDED BY ABINAYA INBAMANI

1.Vehicle maintanance.

#include<iostream> // include input/output library

using namespace std; // use standard namespace

#define size 2 // define constant size as 2
#define MAXKM 50000 // define constant MAXKM as 50000

class vehicle // declare a class called vehicle
{
public :
    string make,model,type; // declare variables for make, model and type of the vehicle
    enum TYPE{GAS,ELECTRIC,DIESEL}; // declare an enum for vehicle type
    int year; // declare variable for year of manufacture
    float odometer; // declare variable for odometer reading

    // declare virtual functions to set and get make, model, year and odometer reading
    virtual void setmake();
    virtual void putmake();
    virtual void setmodel();
    virtual void putmodel();
    virtual void setyear();
    virtual void putyear();
    virtual void setodometer();
    virtual void putodometer();
};

// define the set and put functions for make, model, year and odometer reading
void vehicle::setmake()
{
    cout<<"Enter make of 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) // check if the odometer reading is greater than 50000
        cout<<"\n Tyre rotation to be done "<<endl; // if so, recommend tire rotation
    else
        cout<<"\n less than 50000 kms Tyre rotation can be done in next visit "<< endl; // otherwise, tire rotation can wait
}

// declare a function to display the menu options
void menudisplay()
{
    cout<<"0.Quit.\n ";
    cout<<"1.displayservices.\n ";
    cout<<"2.Addvehicle.\n";
}

// declare a function to display the list of vehicle maintenance tasks
void displayservices()
{
    cout<<"\n oil change or replace oil filter,replace air filter "<< endl;
    cout<<"replace fuel filter,tire rotation ,infotainment delay"<<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 timer conditions, check the charging system,battery"<<endl;
}

int main()
{
    int user_choice; // declare variable for user's menu choice

    beginning: // create a label for the beginning of the loop
    menudisplay(); // display the menu options
    cout<<"Enter your choice in no "<< endl;
    cin>>user_choice; // get user's menu choice

    switch(user_choice) // check the user's menu choice
    {
        case 0: // if the user chooses to quit
            cout<<"Exiting the program";
            break; // exit the loop
        case 1:
        displayservices();
	        goto beginning;
	   case 2:
          vehicle *pv=new vehicle(); // create a new instance of the vehicle class
            pv->setmake(); // set the make of the vehicle
            pv->setmodel(); // set the model of the vehicle
            pv->setyear(); // set the year of manufacture of the vehicle
            pv->setodometer(); // set the odometer reading of the vehicle
            pv->putmake(); // display the make of the vehicle
            pv->putmodel(); // display the model of the vehicle
            pv->putyear(); // display the year of manufacture of the vehicle
            pv->putodometer(); // display the odometer reading of the vehicle
            goto beginning; // jump to beginning of the program
    }
}


OUTPUT

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.