Challenge

Project 3

C++ CODE

#include

using namespace std;

enum Type

{

    GAS,

    DIESEL,

    ELECTRIC

};

class vehicle

{

    protected:

    string make_vehicle, model;

    int year,odometer;

    int Type;

    public:

    vehicle()

    {

       cout<<"Enter the vehicle type\n0 for GAS\n1 for DIESEL\n2 for ELECTRIC\n"<

       cin>>Type;

       switch(Type){

       case GAS :

       cout<<"Gas vehicle "<

       break;

       case DIESEL :

       cout<<"Diesel vehicle "<

       break;

       case ELECTRIC :

       cout<<"Electric vehicle "<

       break;

       }

        cout<<"\nEnter make of the vehicle"<

        cin>>make_vehicle;

        cout<<"Enter the vehicle model : "<< endl>

        cin>>model;

        while ((year<1950>2023))       //year shoule be enter between 1950-2023

        {

            cout<<"Enter the vehicle manufaturing year (1950-2023) : "<< endl>

            cin>>year;

        }

        while ((odometer < 1> 500000))     //below 500000

        {

            cout<<"Enter the odometer reading (below 500000) : "<< endl>

            cin>>odometer; 

        }

    }

};

class service : public vehicle

{

   protected:

   int tire_remaining, battery_remaing;

   public:

   service()

   {

       tire_remaining = 50000 - odometer;

       battery_remaing = 400 - odometer;

   }

void checkTireRotation()

{

    cout << "Tire rotation information: " << endl>

    if(odometer >50000)

       cout<< "The tires need to be changed as their lifetime is over"<

       else

       cout<< "Tire should be change after "<

}

void check_charger_power()

{

    cout << "Battery information: " << endl>

    if (Type==2)

        {

            if(odometer > 400)

             cout<< "The battery need to be charge, battery is too low"<

            else

            cout<< "Check the battery level after "<

        }

    else

    cout<<"This is not Electric vehicle"<

}

void check_oil()

{ 

    cout << "Vehicle oil information: " << endl>

    if (odometer >= 10000)

    {

        cout << "The oil needs to be changed." << endl>

    }

    else 

    {

        cout << "The oil is in good condition. After 10000kms, it will need to be changed." << endl>

    }

}

};

class Vehicle_info : public vehicle 

{      

    protected:

    int customer_vehicle_type;

    public:

    void get_vehicle_info() //function for printing vehicle info

    {

        cout << "Vehicle information: "<

        switch (Type) 

      {

        case GAS:

        cout << "This vehicle runs on liquefied gas." << endl>

        break;

        case DIESEL:

        cout << "This vehicle runs on diesel ." << endl>

        break;

        case ELECTRIC:

        cout << "This vehicle runs on rechargeable battery." << endl>

        break;

        default:

        cout << "Invalid vehicle type selected." << endl>

        break;

      } 

    }

};

int main()

{

   service s;          //object created

   Vehicle_info vi;

   int choice;

   while((choice<6>6)){

    cout << "\nEnter the choice of service (1 to 4): "<

    cout << "\n1. vehicle information\n2. Tire Rotation\n3. check oil condition\n4. check charge power\n5.Quit"<

    cin >> choice;

    switch (choice)

     {

        case 1:

        vi.get_vehicle_info();

        break;

        case 2:

        s.checkTireRotation();

        break;

        case 3:

        s.check_oil();

        break;

        case 4:

        s.check_charger_power();

        break;

        case 5:

        cout<<"Exit the program"<

        exit(0);

     }

 }

    return 0;

}

Output :

Enter the vehicle type

0 for GAS

1 for DIESEL

2 for ELECTRIC

0

Gas vehicle 

Enter make of the vehicle

ford

Enter the vehicle model : 

figo

Enter the vehicle manufaturing year (1950-2023) : 

2003

Enter the odometer reading (below 500000) : 

60000

Enter the vehicle type

0 for GAS

1 for DIESEL

2 for ELECTRIC

2

Electric vehicle 

Enter make of the vehicle

bmw

Enter the vehicle model : 

des

Enter the vehicle manufaturing year (1950-2023) : 

43000

Enter the vehicle manufaturing year (1950-2023) : 

2020

Enter the odometer reading (below 500000) : 

42000

Enter the choice of service (1 to 4): 

1. vehicle information

2. Tire Rotation

3. check oil condition

4. check charge power

5.Quit

1

Vehicle information: 

This vehicle runs on rechargeable battery.

Enter the choice of service (1 to 4): 

1. vehicle information

2. Tire Rotation

3. check oil condition

4. check charge power

5.Quit

2

Tire rotation information: 

The tires need to be changed as their lifetime is over

Enter the choice of service (1 to 4): 

1. vehicle information

2. Tire Rotation

3. check oil condition

4. check charge power

5.Quit

3

Vehicle oil information: 

The oil needs to be changed.

Enter the choice of service (1 to 4): 

1. vehicle information

2. Tire Rotation

3. check oil condition

4. check charge power

5.Quit

4

Battery information: 

This is not Electric vehicle

Enter the choice of service (1 to 4): 

1. vehicle information

2. Tire Rotation

3. check oil condition

4. check charge power

5.Quit

5

Exit the program

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.