Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Theory Icdt 97 6th International Conference Delphi Greece January 8 10 1997 Proceedings Lncs 1186

Authors: Foto N. Afrati ,Phokion G. Kolaitis

1st Edition

3540622225, 978-3540622222

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago