Answer to Question #274021 in C++ for Joy Chepkwemoi

Question #274021

with a custom method called displayVehicle() that displays the details of a vehicle as follows:


If the vehicle is available then it should display the details of a vehicle as the values of the instance variables vehicleID and dailyRate only


Otherwise, if the vehicle is currently on loan it should display the name and license number of the person holding the car as well as the number of days it was rented out. (this obvious includes details above.)




Write a main function that will create 5 Vehicle objects using the data below. Assume all the Vehicles are available initially.


Vehicle ID Daily-Rates ($)


FJH 123N 12.0


DKY 222N 25.0


GAF 333N 18.0


BGH 444N 40.0


FRS 555N 30.0



1
Expert's answer
2021-12-01T10:57:18-0500
class Vehicle
{
private:
    int n, vehicleId, dailyRate;
    Vehicle(int n, int vehicleId, int dailyRate)
    {
        this->dailyRate = dailyRate;
        this->n = n;
        this->vehicleId = vehicleId;
    }


public:
    void display()
    {
        cout << "Daily Rate: " << this->dailyRate << '\n'
             << "Number of vehicles: " << this->n << '\n'
             << "Vehicle ID: " << this->vehicleId << '\n';
    }
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS