Question: c++ code only 9.1 Design a Vehicle class that contains the following properties of motor vehicles: fuel tank capacity, average fuel consumption per 100km, and

c++ code only  c++ code only 9.1 Design a Vehicle class that contains the
following properties of motor vehicles: fuel tank capacity, average fuel consumption per

9.1 Design a Vehicle class that contains the following properties of motor vehicles: fuel tank capacity, average fuel consumption per 100km, and the distance a vehicle can travel on a full tank. The Vehicle class should be designed as an abstract base class from which the Car and Truck classes are derived. The derived classes should have the following member functions: - A function that obtains data for a vehicle from the user - A function that computes and returns the distance a vehicle can travel on a full tank, if given the fuel tank capacity and average fuel consumption - A function that computes and returns how many times a vehicle has to be refueled to travel a given distance - A function that displays data for a vehicle These functions should be defined in the Vehicle class and inherited by the derived classes. The function that obtains a vehicle data from the user and the function that displays a vehicle data should be created as pure virtual functions in Vehicle and redefined by the derived classes. In addition to data members inherited from Vehicle, the derived classes should also have some other data members that are specific to a particular type of a vehicle. Design the main() function that instantiates a pointer of Vehi cle type, and a Car and Truck object, respectively. The pointer should be used to invoke appropriate member functions to get, process, and display data for a car and truck. The program should output all of the vehicles' data, including how many times each vehicle has to be refueled to travel the distance entered by the user, as well as the distance each vehicle can travel on a full tank

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!