Question

In: Computer Science

Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping options, each...

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 TwoDayPackage and OvernightPackage 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 calculateCost that returns a double indicating the cost associated with shipping the package. Package’s calculateCost function should determine the cost by multiplying the weight by the cost per ounce. Package should also provide the public member function displayShippingDetail which outputs the sender and recipient information (see below for example). Derived class TwoDayPackage 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. TwoDayPackage’s constructor should receive a value to initialize this data member. TwoDayPackage should redefine member function calculateCost so that it computes the shipping cost by adding the flat fee to the weight-based cost calculated by base class Package’s calculateCost function. Class OvernightPackage should inherit directly from class Package and contain an additional data member representing an additional fee per ounce charged for overnight-delivery service. OvernightPackage should redefine member function calculateCost 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 calculateCost.

Sample

Package 
To: 
Ben Stiller
89 N Brooke Dr Brooklyn, NY 02142

From: 
Macy Gray
89 Wisconsin Ave Seattle, WA 42512-9031
Total: $11.41

Two Day Package 
To: 
Ken Mattingly
7888 Ventura Highway Titusville, FL 32933

From: 
Dave Letterman
2313 Fairview Way Poughkeepsie, NY 12604
Total: $31.99

Overnight Package 
To: 
Toby Zeigler
1600 Pennsylvania Ave NW Washington, DC 20500

From: 
Joey Lucas
522 N Maple Dr Beverly Hills, CA 90210
Total: $81.12

Hello I need a overnightPackage .cpp file and overnightPackage .h file, package .cpp file and package .h file, main .cpp file, and lastly TwoDayPackage .cpp file and TwoDayPackage .h file.

I need all this code in C++

Solutions

Expert Solution

using System;

public class Package

{

string senderName11;

string senderAddress1;

string senderCity1;

string senderState1;

string senderZip1;

string recipientName1;

string recipientAddress1;

string recipientCity1;

string recipientState1;

string recipientZip1;

decimal weight1;

decimal costPerOunce1;

public string SenderName11

{

get { return senderName11; }

set { senderName11 = value; }

}

public string SenderAddress1

{

get { return senderAddress1; }

set { senderAddress1 = value; }

}

public string SenderCity1

{

get { return senderCity1; }

set { senderCity1 = value; }

}

public string SenderState1

{

get { return senderState1; }

set { senderState1 = value; }

}

public string SenderZip1

{

get { return senderZip1;}

set { senderZip1 = value; }

}

public string RecipientName1

{

get { return recipientName1; }

set { recipientName1 = value; }

}

public string RecipientAddress1

{

get { return recipientAddress1; }

set { recipientAddress1 = value; }

}

public string RecipientCity1

{

get { return recipientCity1; }

set { recipientCity1 = value; }

}

public string RecipientState1

{

get { return recipientState1; }

set { recipientState1 = value; }

}

public string RecipientZip1

{

get { return recipientZip1; }

set { recipientZip1 = value; }

}

public decimal Weight1

{

get { return weight1; }

set

{

if (value > 0)

weight1 = value;

else

Console.WriteLine("Weight1 can't be less tha zero");

}

}

public decimal CostPerOunce1

{

get { return costPerOunce1; }

set

{

if (value > 0)

costPerOunce1 = value;

else

Console.WriteLine("Cost per ounce can't be less than zero");

}

}

public Package

(

string senderName11,

string senderAddress1,

string senderCity1,

string senderState1,

string senderZip1,

string recipientName1,

string recipientAddress1,

string recipientCity1,

string recipientState1,

string recipientZip1,

decimal weight1,

decimal costPerOunce1

)

{

SenderName11 = senderName11;

SenderAddress1 = senderAddress1;

SenderCity1 = senderCity1;

SenderState1 = senderState1;

SenderZip1 = senderZip1;

RecipientName1 = recipientName1;

RecipientAddress1 = recipientAddress1;

RecipientCity1 = recipientCity1;

RecipientState1 = recipientState1;

RecipientZip1 = recipientZip1;

Weight1 = weight1;

CostPerOunce1 = costPerOunce1;

}

public virtual decimal CalculateCost()

{

return weight1 * costPerOunce1;

}

}

public class TwoDayPackage : Package

{

decimal twoDayDeliveryFee;

public decimal TwoDayDeliveryFee

{

get { return twoDayDeliveryFee; }

set { twoDayDeliveryFee = value; }

}

public TwoDayPackage

(

string senderName11,

string senderAddress1,

string senderCity1,

string senderState1,

string senderZip1,

string recipientName1,

string recipientAddress1,

string recipientCity1,

string recipientState1,

string recipientZip1,

decimal weight1,

decimal costPerOunce1,

decimal twoDayDeliveryFee

)

: base

(

senderName11,

senderAddress1,

senderCity1,

senderState1,

senderZip1,

recipientName1,

recipientAddress1,

recipientCity1,

recipientState1,

recipientZip1,

weight1,

costPerOunce1

)

{

TwoDayDeliveryFee = twoDayDeliveryFee;

}

public override decimal CalculateCost()

{

return base.CalculateCost() + TwoDayDeliveryFee;

}

}

public class OvernightPackage : Package

{

decimal overnightDeliveryFeePerOunce;

public decimal OvernightDeliveryFeePerOunce

{

get { return overnightDeliveryFeePerOunce; }

set { overnightDeliveryFeePerOunce = value; }

}

public OvernightPackage

(

string senderName11,

string senderAddress1,

string senderCity1,

string senderState1,

string senderZip1,

string recipientName1,

string recipientAddress1,

string recipientCity1,

string recipientState1,

string recipientZip1,

decimal weight1,

decimal costPerOunce1,

decimal overnightDeliveryFeePerOunce

)

: base

(

senderName11,

senderAddress1,

senderCity1,

senderState1,

senderZip1,

recipientName1,

recipientAddress1,

recipientCity1,

recipientState1,

recipientZip1,

weight1,

costPerOunce1

)

{

OvernightDeliveryFeePerOunce = overnightDeliveryFeePerOunce;

}

public override decimal CalculateCost()

{

return (CostPerOunce1 + OvernightDeliveryFeePerOunce) * Weight1;

}

}

class TestPackages

{

static void Main(string[] args)

{

Package regularPackage = new Package

(

"Peter Anderson",

"123 Main St, Ashville, NC 27111 ",

"Ashville",

"NC 27111",

"MN 55416",

"Mary Brown",

"456 Broad St Benson, NC 27222",

"St. Petersburg",

"Benson",

"NC 27222",

160M,

0.1M

);

Console.WriteLine("\nRegular Package: ");

Console.WriteLine(" Sender's Name: {0}",

regularPackage.SenderName11);

Console.WriteLine(" Sender's Address: {0}",

regularPackage.SenderAddress1);

Console.WriteLine(" Recipient's Name: {0}",

regularPackage.RecipientName1);

Console.WriteLine(" Recipient's Address: {0}",

regularPackage.RecipientAddress1);

Console.WriteLine(" Weight1: {0}"

, regularPackage.Weight1);

Console.WriteLine(" Cost Per Ounce: {0:C}",

regularPackage.CostPerOunce1);

Console.WriteLine("Shipping Cost: {0:C}",

regularPackage.CalculateCost());

Console.WriteLine(regularPackage.CalculateCost());

TwoDayPackage twoDayPackage = new TwoDayPackage

(

"Peter Anderson",

"123 Main St 123 Main St, Ashville, NC 27111",

"Ashville",

"NC 27111",

"MN 55416",

"Mary Brown",

"456 Broad St",

"St. Petersburg",

"Benson",

"NC 27222",

160M,

0.1M,

1.5M

);

Console.WriteLine("\nTwo-Day Package: ");

Console.WriteLine(" Sender's Name: {0}",

twoDayPackage.SenderName11);

Console.WriteLine(" Sender's Address: {0}",

twoDayPackage.SenderAddress1);

Console.WriteLine(" Recipient's Name: {0}",

twoDayPackage.RecipientName1);

Console.WriteLine(" Recipient's Address: {0}",

twoDayPackage.RecipientAddress1);

Console.WriteLine(" Weight1: {0}", twoDayPackage.Weight1);

Console.WriteLine(" Cost Per Ounce: {0:C}",

twoDayPackage.CostPerOunce1);

Console.WriteLine(" Flat Fee: {0:C}",

twoDayPackage.Weight1);

Console.WriteLine(" Shipping Cost: {0:C}",

twoDayPackage.CalculateCost());

OvernightPackage overnightPackage = new OvernightPackage

(

"Peter Anderson",

"123 Main St 123 Main St, Ashville, NC 27111",

"Ashville",

"NC 27111",

"MN 55416",

"Mary Brown",

"456 Broad St Benson, NC 27222",

"St. Petersburg",

"Benson",

"NC 27222",

160M,

0.1M,

1.5M

);

Console.WriteLine("\nOvernight Package: ");

Console.WriteLine(" Sender's Name: {0}",

overnightPackage.SenderName11);

Console.WriteLine(" Sender's Address: {0}",

overnightPackage.SenderAddress1);

Console.WriteLine(" Recipient's Name: {0}",

overnightPackage.RecipientName1);

Console.WriteLine(" Recipient's Address: {0}",

overnightPackage.RecipientAddress1);

Console.WriteLine(" Weight1: {0}",

overnightPackage.Weight1);

Console.WriteLine(" Cost Per Ounce: {0:C}",

overnightPackage.CostPerOunce1);

Console.WriteLine(" Additional Cost Per Ounce: {0:C}",

overnightPackage.OvernightDeliveryFeePerOunce);

Console.WriteLine(" Shipping Cost: {0:C}",

overnightPackage.CalculateCost());

Console.WriteLine(overnightPackage.CalculateCost()); Console.ReadKey();

}

}

Output-


Related Solutions

use c++ Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number...
use c++ 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 TwoDayPackage and OvernightPackage 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,...
1. Do FedEx and UPS offer the same delivery services, or has each chosen to focus...
1. Do FedEx and UPS offer the same delivery services, or has each chosen to focus on different forms of delivery and/or customer needs? Explain
A large logistics fleet company such as UPS, DHL or FedEx is trying to figure out...
A large logistics fleet company such as UPS, DHL or FedEx is trying to figure out supply chain costs for a small supply chain facility. You have been asked to step in as a supply chain consultant. The company has identified the following costs.             Number of trucks used per day in the fleet:                           20 trucks (1 driver each)             Cost per delivery driver for each truck per hour:                   $10             Number of hours of delivery per day:                                     10 hours per day             Number of Driving days...
Evaluate the competitive nature within the air delivery and freight services industry (think UPS and FedEx)...
Evaluate the competitive nature within the air delivery and freight services industry (think UPS and FedEx) using Porter’s Five Forces.
Suppose that for a typical FedEx package delivery, the cost of the shipment is a function...
Suppose that for a typical FedEx package delivery, the cost of the shipment is a function of the weight of the package. You find out that the regression equation for this relationship is (cost of delivery) = 0.728*(weight) + 5.49. If a package you want to ship weighs 13.753 ounces and the true cost of the shipment is $12.229, the residual is -3.273. Interpret this residual in terms of the problem. Question 5 options: 1) The weight is 3.273 points...
1.       United Parcel Service (UPS) provides package delivery services throughout the United States and the world. Discuss...
1.       United Parcel Service (UPS) provides package delivery services throughout the United States and the world. Discuss the impact of seasonal variations in the delivery business for forecasting the firm’s financing requirements. 2.       Dell Computer Corporation (DELL) has long been recognized for its innovative approach to managing its working capital. Describe how Dell pioneered the management of net working capital to free up resources in the firm.
In the early 2000’s, DHL expanded its worldwide air express package delivery service to the US...
In the early 2000’s, DHL expanded its worldwide air express package delivery service to the US market in direct competition with UPS and FedEx. After several years and more than one billion dollars in losses, DHL admitted defeat in 2008 withdrawing from most US markets while shedding some 15,000 US jobs. Think back to DHL announcement of its intention to enter the US market. Various stakeholders would greet the prospect of increased competition differently. In this discussion forum, address the...
UPS and FedEx Case Study Success for a company comes in many different forms. It could...
UPS and FedEx Case Study Success for a company comes in many different forms. It could be the bottom line, expanding market share, or pushing the boundaries of sustainability. Using the FedEx and UPS Documentary case study video and your own research, analyze the effect that either UPS or FedEx has had on the modern economy. When you are finished with your research, list and explain at least two effects that the company has had on the economy. Focusing on...
Question 3 : A package delivery company is contemplating building a new shipping center. The most...
Question 3 : A package delivery company is contemplating building a new shipping center. The most recent shipping center, 10,000 square feet large, was built in 2005, at a cost of $500,000. The new shipping center will be 15,000 square feet large. Using the power-sizing cost-estimating model, estimate the cost of building a new shipping center now, using the assumptions below to construct a weighted cost index value for 2005 and for today. Use 0.90 for the cost-capacity factor. The...
       Define market segmentation and discuss the different options available to financial services organisations in deciding...
       Define market segmentation and discuss the different options available to financial services organisations in deciding on the bases to use in segmenting the personal sector.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT