Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question: (Package Inheritance Hierarchy) Use the Package inheritance hierarchy created in Exercise to create a program that displays the address information and calculates the shipping costs for several Packages. The program should contain a vector of Package pointers to objects of classes Two Day Package and Over night Package. Loop through the vector to process the Packages polymorphically. For each Package, invoke get functions to obtain the address information of the sender and the recipient, then print the two addresses as they would appear on mailing labels. Also, call each Package's calculate Cost member function and print the result. Keep track of the total shipping cost for all Packages in the vector, and display this total when the loop terminates.

Exercise: (Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping options, each with specific costs associated. Create an inheritance hierarchy to represent various types of packages. Use class Package as the base class of the hierarchy, then include classes Two Day Package and Over night Package that derive from Package. Base class Package should include data members representing the name, address, city, state and ZIP code for both the sender and the recipient of the package, in addition to data members that store the weight (in ounces) and cost per ounce to ship the package. Package's constructor should initialize these data members. Ensure that the weight and cost per ounce contain positive values. Package should provide a public member function calculate Cost that returns a double indicating the cost associated with shipping the package. Package's calculate Cost function should determine the cost by multiplying the weight by the cost per ounce. Derived class Two Day Package should inherit the functionality of base class Package, but also include a data member that represents a flat fee that the shipping company charges for two-day-delivery service. Two Day Package's constructor should receive a value to initialize this data member. Two Day Package should redefine member function calculate Cost so that it computes the shipping cost by adding the flat fee to the weight-based cost calculated by base class Package's calculate Cost function. Class Over night Package should inherit directly from class Package and contain an additional data member representing an additional fee per ounce charged for overnight-delivery service. Over night Package should redefine member function calculate Cost so that it adds the additional fee per ounce to the standard cost per ounce before calculating the shipping cost. Write a test program that creates objects of each type of Package and tests member function calculate Cost.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92419019
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Assignment -note in your assignment how you arrived at your

Assignment - Note: In your assignment, how you arrived at your solution is as important (if not more so) than the solution itself and will be assessed accordingly. There may be more than one way to find a solution, and y ...

What data management considerations must be reviewed to

What data management considerations must be reviewed to ensure success for both companies and assure regulatory compliance, ethical responsibility, and business performance?

Please help with anbspfunctionnbspcodesymbol to convert

Please help with a function  codeSymbol , to convert each mark to a symbol (A, B, C, D, E, F) and a code (7,6,5,4,3,2,1) according to the table below. And call it in the main function. Use the table below to determine th ...

Youre trying to save to buy a new 190000 bmw 3 series

You're trying to save to buy a new $190,000 BMW 3 series sedan. You have $40,000 today that can be invested t your bank. The bank pays 4.8% annual interest on its accounts.  How long will it be before you have enough to ...

The single-cycle design on p 17 of the notes is capable of

The single-cycle design on p. 17 of the notes is capable of performing more instructions than the subset that were discussed in §4.1 of the lecture notes. Open the MIPS Architecture Volume II-A: The MIPS32 Instruction Se ...

Discuss how today the internet has brought millions of

Discuss how today, the internet has brought millions of unsecured computer networks into communication with each other.

Question suppose that we want to create a divide and

Question : Suppose that we want to create a divide and conquer matrix multiplication algorithm for square matrices. Assuming that n is a power of three, the algorithm divides each matrix of A, D, and C into nine equi-siz ...

Question part 1 analyze the case study titled vodafone a

Question: Part 1: Analyze the case study titled "Vodafone: A Giant Global ERP Implementation" (below) For this assignment, you will need to: 1. analyze and discuss the central issue(s) faced by Vodafone, including the co ...

Answer the question given belowwhat is the relationship

Answer the question given below What is the relationship between a context diagram and diagram 0, and which symbol is not used in a context diagram? The response must be typed, single spaced, must be in times new roman f ...

Display the manager of the employee with the oldest project

Display the manager of the employee with the oldest project start date (start_date). (This query requires 3 nested queries, start by finding the min start_date from project, then find the emp_id from project where start_ ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As