I am facing some problem on solving this problem, can anyonegive me some idea ho
ID: 3619238 • Letter: I
Question
I am facing some problem on solving this problem, can anyonegive me some idea how can I solved this problem? Package-delivery services, such as FedEx®, DHL® andUPS®, offer a number of different shipping options, each withspecific costs associated. Create an inheritance hierarchy torepresent various types of packages. Use Package as the base classof the hierarchy, then include classes TwoDayPackage andOvernightPackage that derive from Package. Base class Packageshould include data members representing the name, address, city,state and ZIP code for both the sender and the recipient of thepackage, in addition to data members that store the weight (inounces) and cost per ounce to ship the package. Package'sconstructor should initialize these data members. Ensure that theweight and cost per ounce contain positive values. Package shouldprovide a public member function calculateCost that returns adouble indicating the cost associated with shipping the package.Package's calculateCost function should determine the cost bymultiplying the weight by the cost per ounce. Derived classTwoDayPackage should inherit the functionality of base classPackage, but also include a data member that represents a flat feethat the shipping company charges for two-day-delivery service.TwoDayPackage's constructor should receive a value to initializethis data member. TwoDayPackage should redefine member functioncalculateCost so that it computes the shipping cost by adding theflat fee to the weight-based cost calculated by base classPackage's calculateCost function. Class OvernightPackage shouldinherit directly from class Package and contain an additional datamember representing an additional fee per ounce charged forovernight-delivery service. OvernightPackage should redefine memberfunction calculateCost so that it adds the additional fee per ounceto the standard cost per ounce before calculating the shippingcost. Write a test program that creates objects of each type ofPackage and tests member function calculateCost.I am facing some problem on solving this problem, can anyonegive me some idea how can I solved this problem?
Explanation / Answer
x.p]5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.