Question: C++ Program Create an inheritance hierarchy for the following types of vehicles: Bicycle, Car, Truck, Train. Using polymorphism, have a function that calculates the 'carbon
C++ Program
Create an inheritance hierarchy for the following types of vehicles: Bicycle, Car, Truck, Train. Using polymorphism, have a function that calculates the 'carbon footprint' for each.
Formulas to calculate the footprint: Bicycle - 0 Car - less than 2000 lbs - 3 tons of CO2 for every 200 hours of running time - 2000 lbs or more - 5 tons of CO2 for every 200 hours of running time Truck - under 150 HP - 3 tons of CO2 for every 200 hours of running time - 150 HP and over - 5 tons of CO2 for every 200 hours of running time Train - less than 4 years old - 60 tons of CO2 for every 2000 hours of running time - 4 years or older - 100 tons of CO2 for every 2000 hours of running time
In main 1. Instantiate an object of each of the different types. - Car - weight of 2345 lbs and 500 hours of running time - Truck - 300 HP and 750 hours of running time - Train - 10 years old and 17000 hours of running time 2. Call a global function that returns the 'carbon footprint' - use polymorphism
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
