1answer.
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
gayaneshka [121]
3 years ago
6

In this lab, you will build a system for package delivery services that provides different shipping options with specific price.

You are required to create an inheritance hierarchy to represent the various types of packages. Use Package as the base class of the hierarchy and include classes TwoDaypackage and OvernightPackage that derive from Package. The 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, and data members that store the weight (in ounces) and cost per ounce to ship the package. The constructor of the class Package should initialize these data members. The weight and the cost per ounce should contain positive values. The class Package should provide a public member function calculateCost that returns a double indicating the cost associated with shipping the package. The calculateCost function in class Package should determine the cost by multiplying the weight by the cost per ounce. The derived class TwoDayPackage should not only inherit the functionality of the base class Package, but also include a data member that represents a flat fee per ounce that the shipping company charges for two-day delivery. The constructor of the class TwoDayPackage should receive a value to initialize this data member. Class TwoDayPackage should redefine member function calculateCost so that it computes the shipping cost by adding a flat fee per ounce to the standard cost per ounce calculated by the calculateCost function in the base class Package. The requirements of the derived class OvernightPackage are similar as that of the class TwoDayPackage. Specifically, class OvernightPackage should inherit directly from class Package and contain an additional data member representing an additional flat fee per ounce charged for overnight delivery. Class OvernightPackage should redefine member function calculateCost so that it adds the additional fee per ounce to the standard cost per ounce when calculating the shipping cost.
Computers and Technology
1 answer:
Alex73 [517]3 years ago
8 0

Answer:

See explaination

Explanation:

#include <iostream>

#include <string.h>

using namespace st d;

class Package

{

protected:

//sender properities

char sname[10],saddress[50],scity[20],sstate[20];

long int szip;

//Receiver properities

char rname[10],raddress[50],rcity[20],rstate[20];

long int rzip;

//additonal datamembers

float weight,cost;

public:

Package() //Default constructor

{

strcpy(sname,"");strcpy(saddress,"");strcpy(scity,"");

strcpy(sstate,"");szip=0;

strcpy(rname,"");strcpy(raddress,"");strcpy(rcity,"");

strcpy(rstate,"");rzip=0;

weight=cost=0;

}

Package(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c) //Constructor with parameter

{

strcpy(sname,sn);strcpy(saddress,sa);strcpy(scity,sc); //copying each parameter value to data member

strcpy(sstate,ss);szip=0;

strcpy(rname,rn);strcpy(raddress,ra);strcpy(rcity,rc);

strcpy(rstate,rs);rzip=0;

weight=w;cost=c;

}

float calculateCost() //calculating cost

{

return weight*cost;

}

};

class TwoDayPackage:public Package //Inheritance

{

float flatfee;

public:

TwoDayPackage(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c,float ff) //Constructor with parameter

{

Package(sn,sa,sc,ss,sz,rn,ra,rc,rs,rz,w,c); //calling super class constructor

flatfee=ff; //copy last parameter

}

float calculateCost() //redefined calculateCost function

{

return (weight*cost)+flatfee; //return total cost

}

};

class OverNightPackage:public Package //Inheritance

{

float addfee;

public:

OverNightPackage(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c,float a f) //constructor with parameter

{

Package(sn,sa,sc,ss,sz,rn,ra,rc,rs,rz,w,c); //calling super class constructor

addfee=a f; //copy last parameter

}

float calculateCost() //redefined calculateCost function

{

return (weight*cost)+addfee; //calculating total cost

}

};

int main()

{

Package package1("lou brown","1 main st","boston","ma",11111,"mary smith","7 elm st","new york","ny",22222,8.5,0.5); //creating objects

TwoDayPackage package2("lisa klein", "5 broadway", "somerville", "ma", 33333, "bob george", "21 pine rd", "cambridge", "ma", 44444, 10.5, .65, 2.0 );

OverNightPackage package3 ("ed lewis", "2 oak st", "boston", "ma", 55555, "don kelly", "9 main st", "denver", "co", 66666, 12.25, .7, .25 );

cout<<"\nPackage Cost : "<<package1.calculateCost(); //calling each cost

cout<<"\nTwoDay Package Cost : "<<package2.calculateCost();

cout<<"\nOvernight Package Cost : "<<package3.calculateCost();

return 0;

}

You might be interested in
Why was the term personal computer created?
tresset_1 [31]
It was created to show the difference between computers that were owned by companies (at one point they were so large and so expensive that only big groups could afford and store them), and the era when computers became small enough for individuals to be able to fit them in their own homes, and also afford them. The era of the Personal Computer (PC) was a huge changing point in history because it brought a lot of power and connectivity into people's homes that hadn't been available before.
3 0
3 years ago
Is TCP really more secure than other L4 protocols by default?
yulyashka [42]

Answer:

Yes TCP is

Explanation:

3 0
1 year ago
Jjhb ft fv tuning Denise l Debbie
Vitek1552 [10]
What








What the debbie



7 0
3 years ago
HELP ME ILL GIVE BRAINLY Input 50 numbers and then output the average of the negative numbers only. Write in pseudocode!
Mumz [18]

Answer:

The explanation is for 10 inputs though. You'd have to follow these steps to find input 50 numbers.

Explanation:

This is how I wrote it in the Plain English programming language which looks like pseudo-code but compiles and runs (to save you all the rest of the steps):

To run:

Start up.

Write "Enter 10 numbers separated by spaces: " on the console.

Read a reply from the console.

Loop.

If the reply is blank, break.

Get a number from the reply.

Add 1 to a count.

Add the number to a total.

Repeat.

Write "The total is: " then the total on the console.

Put the total divided by the count into an average.

Write "The average is: " then the average on the console.

Refresh the screen.

Wait for the escape key.

Shut down.

3 0
2 years ago
There is an interface I that has abstract class AC as its subclass. Class C inherits AC. We know that C delegates to an object o
Aloiza [94]

Answer:

are u in HS or college work

I am trying to understand

6 0
2 years ago
Other questions:
  • George and Miguel want to know more about their local and online competitors and about the retail industry. What is the best way
    9·1 answer
  • A database interrogation is a major benefit of the database management approach, where end users can query (“ask”) the database
    6·1 answer
  • Assuming there are 100 million households in the US, and that each household has two HDTVs, and that each TV is used to watch 4
    15·1 answer
  • A(n) ____ string contacts the data source and establishes a connection with the database using the Data Source Configuration Wiz
    5·1 answer
  • Combining two or more cells to make one is called​
    8·1 answer
  • Which statement describes how to insert the IF, COUNTIF, or SUM function into a cell?
    11·1 answer
  • LAB: Convert to binary - methods
    11·1 answer
  • You press the F9 key to convert an object to a symbol true or false​
    12·1 answer
  • Lol WAKE UP!!! and get ready to answer my questions.
    12·1 answer
  • Dragging a mouse over text is called
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!