answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
makvit [3.9K]
2 years ago
10

(Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping o

ptions, 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.

Computers and Technology
1 answer:
lys-0071 [83]2 years ago
8 0

Answer:

Check the explanation

Explanation:

note: code is implemented as per the main method provided:

code:

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");

)

{

SenderName11 = senderName11;

SenderAddress1 = senderAddress1;

)

{

TwoDayDeliveryFee = twoDayDeliveryFee;

}

public override decimal CalculateCost()

{

return base.CalculateCost() + TwoDayDeliveryFee;

}

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();

}

}

The Result can be seen below:

You might be interested in
WILL MARK BRAINLIEST HELP
hichkok12 [17]

My guess would be A.

3 0
2 years ago
Read 2 more answers
Which of the following is not one of the four criteria for evaluating websites?
Flura [38]

Answer:validity

Explanation:

Because it dont sound right

5 0
2 years ago
Here is a super challenge for you if you feel up for it. (You will need to work this out in Excel.) In 2017 the Islamic month of
Ann [662]

Answer:

7/73

Explanation:

May has 31 days. 31 - 26 = 5. So there are 5 more days to the next month (June). June has 30 days. So Muslims fasted 35 days in total. 2017 had 365 days. 365 - 35 = 330 days were spent not fasting. So the fraction is 35/365. This fraction simplified would be 7/73.

4 0
2 years ago
2. Sanjay thinks it's okay to plagiarize because he thinks his instructors won't find out. However, it's
Tatiana [17]
The correct answer is B
8 0
2 years ago
Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number w
Gre4nikov [31]

Answer:

numInsects = 16

while numInsects < 200:

   print(str(numInsects) + " ", end="")

   numInsects *= 2

Explanation:

*The code is in Python.

Set the numInsects as 16

Create a while loop that iterates while numInsects is smaller than 200. Inside the loop, print the value of numInsects followed by a space. Then, multiply the numInsects by 2.

3 0
2 years ago
Other questions:
  • If you want to present slides to fellow students or coworkers which productivity software should you use to create them A. Word
    14·2 answers
  • PLEASE HELP!! WILL GIVE BRAINLIEST!!
    15·2 answers
  • On the Picture Tools Layout tab, you can preview results of the numerous styles, borders, effects, and layouts by _______ comman
    7·2 answers
  • When you examine a computer chip under a microscope, what will you see?
    6·1 answer
  • Grabar microphone audio icon_person click each item to hear a list of vocabulary words from the lesson. then, record yourself sa
    7·2 answers
  • Susie works for an architectural firm and the partners have always drawn the plans for projects by hand. Though Susie learned ho
    11·1 answer
  • Information systems cannot solve some business problems. Give three examples and explain why technology cannot help.
    11·1 answer
  • Which of these are characteristics of a Python data type? Check all that apply.
    11·1 answer
  • A large number of genetic codes are stored as binary values in a list. Which one of the following conditions must be true in ord
    5·2 answers
  • Which are technical and visual demands that need to be considered when planning a project? Choose three answers
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!