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
JAVA Write a program that first asks the user to type a letter grade and then translates the letter grade into a number grade. L
ale4655 [162]

Answer:

Follows are the code to this question:

import java.util.*;//import package for user input

class GradePrinter//defining class GradePrinter

{

double numericValue = 0;//defining double variable

String grade = "";//defining String variable

GradePrinter()//defining default constructor  

{

Scanner xb = new Scanner(System. in );//defining Scanner  class object

System.out.print("Enter Grade: ");//print message

grade = xb.nextLine();//input string value  

}

double getNumericGrade()//defining double method getNumericGrade

{

if (grade.equals("A+") || grade.equals("A"))//defining if block that check input is A+ or A

{

numericValue = 4.0;//using  numericValue variable that hold float value 4.0

}

else if (grade.equals("A-"))//defining else if that check grade equals to A-

{

numericValue = 3.7;//using  numericValue variable that hold float value 3.7

}

else if (grade.equals("B+"))//defining else if that check grade equals to B-

{

numericValue = 3.3;//using  numericValue variable that hold float value 3.3

}

else if (grade.equals("B"))//defining else if that check grade equals to B

{

numericValue = 3.0;//using  numericValue variable that hold float value 3.0

}

else if (grade.equals("B-"))//defining else if that check grade equals to B-  

{

numericValue = 2.7;//using  numericValue variable that hold float value 2.7

}

else if (grade.equals("C+"))//defining else if that check grade equals to C+  

{

numericValue = 2.3; //using  numericValue variable that hold float value 2.3

}

else if (grade.equals("C")) //defining else if that check grade equals to C  

{

numericValue = 2.0; //using numericValue variable that hold float value 2.0

}

else if (grade.equals("C-")) //defining else if that check grade equals to C-  

{

numericValue = 1.7;//using umericValue variable that hold float value 1.7

}

else if (grade.equals("D+"))//defining else if that check grade equals to D+  

{

numericValue = 1.3;//using umericValue variable that hold float value 1.3

}

else if (grade.equals("D"))//defining else if that check grade equals to D

{

numericValue = 1.0;//using umericValue variable that hold float value 1.0

}

else if (grade.equals("F"))//defining else if that check grade equals to F

{

numericValue = 0;//using umericValue variable that hold value 0

}

else//defining else block

{

System.out.println("Letter not in grading system");//print message

}

return numericValue;//return numericValue

}

}

class Main//defining a class main

{

public static void main(String[] args)//defining main method

{

GradePrinter ob = new GradePrinter();// creating class GradePrinter object

double numericGrade = ob.getNumericGrade();//defining double variable numericGrade that holds method Value

System.out.println("Numeric Value: "+numericGrade); //print Value numericgrade.

}

}

Output:

Enter Grade: B

Numeric Value: 3.0

Explanation:

In the above-given code, a class "GradePrinter" is defined inside the class a string, and double variable "grade and numericValue" is defined, in which the grade variable is used for input string value from the user end.

After input, the sting value a method getNumericGrade is defined, which uses multiple conditional statements is used, which holds double value in the which is defined in the question.

In the main class, the "GradePrinter" object is created and defines a double variable "numericGrade", that calling method and store its value, and also use print method to print its value.

4 0
2 years ago
8.Change the following IP addresses from binary notation to dotted-decimal notation: a.01111111 11110000 01100111 01111101 b.101
Andrews [41]

Answer:

a. 01111111 11110000 01100111 01111101 dotted decimal notation:

(127.240.103.125)

b. 10101111 11000000 11111000 00011101 dotted decimal notation: (175.192.248.29)

c. 11011111 10110000 00011111 01011101 dotted decimal notation:

(223.176.31.93)

d. 11101111 11110111 11000111 00011101 dotted decimal notation:

(239.247.199.29)

a. 208.34.54.12 class is C

b. 238.34.2.1 class is D

c. 242.34.2.8 class is E

d. 129.14.6.8 class is B

a.11110111 11110011 10000111 11011101 class is E

b.10101111 11000000 11110000 00011101 class is B

c.11011111 10110000 00011111 01011101 class is C

d.11101111 11110111 11000111 00011101 class is D

Explanation:

8 a. 01111111 11110000 01100111 01111101

we have to convert this binary notation to dotted decimal notation.

01111111 = 0*2^7 + 1*2^6 + 1*2^5 + 1*2^4 + 1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

           = 0 + 1*64 + 1*32 + 1*16 + 1*8 + 1*4 + 1*2 + 1

           = 64 + 32 + 16 + 8 + 4 + 2 + 1

           = 127

11110000 = 1*2^7 + 1*2^6 + 1*2^5 + 1*2^4 + 0*2^3 + 0*2^2 + 0*2^1 + 0*2^0

               = 1*128 + 1*64 + 1*32 + 16 + 0 + 0 + 0 + 0

               = 128 + 64 + 32 + 16

               = 240

01100111 = 0*2^7 + 1*2^6 + 1*2^5 + 0*2^4 +0*2^3 + 1*2^2 + 1*2^1 + 1*2^0

               = 0 + 1*64 + 1*32 + 0 + 0 + 4 + 2 + 1

               = 64 + 32 + 4 + 2 + 1

               = 103

01111101   = 0*2^7 + 1*2^6 + 1*2^5+ 1*2^4 +1*2^3 +1*2^2 + 0*2^1 + 1*2^0

               = 0 + 1*64 + 1*32 + 1*16 + 1*8 + 1* 4 + 0 + 1

               = 64 + 32 + 16 + 8 + 4 + 1

               = 125

So the IP address from binary notation 01111111 11110000 01100111 01111101 to dotted decimal notation is : 127.240.103.125

b) 10101111 11000000 11111000 00011101

10101111 = 1*2^7 + 0*2^6 + 1*2^5 + 0*2^4 + 1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

             = 175

11000000 = 1*2^7 + 1*2^6 + 0*2^5 + 0*2^4 + 0*2^3 + 0*2^2 + 0*2^1 + 0*2^0

                 = 192

11111000 = 1*2^7 + 1*2^6 + 1*2^5 + 1*2^4 +1*2^3 + 0*2^2 + 0*2^1 + 0*2^0

              = 248

00011101 = 0*2^7 + 0*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 0*2^1 + 1*2^0

               = 29

So the IP address from binary notation 10101111 11000000 11111000 00011101  to dotted decimal notation is : 175.192.248.29

c) 11011111 10110000 00011111 01011101

11011111 = 1*2^7 + 1*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

           = 223

10110000 =  1*2^7 + 0*2^6 + 1*2^5 + 1*2^4 +0*2^3 + 0*2^2 + 0*2^1 + 0*2^0

                = 176

00011111 = 0*2^7 + 0*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

              = 31

01011101 = 0*2^7 + 1*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 0*2^1 + 1*2^0

              = 93

So the IP address from binary notation 11011111 10110000 00011111 01011101 to dotted decimal notation is :223.176.31.93

d) 11101111 11110111 11000111 00011101

11101111 = 1*2^7 + 1*2^6 + 1*2^5 + 0*2^4 +1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

            = 239

11110111 = 1*2^7 + 1*2^6 + 1*2^5 + 1*2^4 +0*2^3 + 1*2^2 + 1*2^1 + 1*2^0

           = 247

11000111 =  1*2^7 + 1*2^6 + 0*2^5 + 0*2^4 +0*2^3 + 1*2^2 + 1*2^1 + 1*2^0

              = 199

00011101 = 0*2^7 + 0*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 0*2^1 + 1*2^0

               = 29

So the IP address from binary notation 11101111 11110111 11000111 00011101 to dotted decimal notation is : 239.247.199.29

9. In order to the find the class check the first byte of the IP address which is first 8 bits and check the corresponding class as follows:                

Class A is from 0 to 127

Class B is from 128 to 191

Class C is from 192 to 223

Class D is from 224 to 239

Class E is from 240 to 255

a. 208.34.54.12

If we see the first byte of the IP address which is 208, it belongs to class C as class C ranges from 192 to 223.

b. 238.34.2.1

If we see the first byte of the IP address which is 238, it belongs to class D as Class D ranges from 224 to 239.

c. 242.34.2.8

If we see the first byte of the IP address which is 242, it belongs to class E as Class E ranges from 240 to 255.

d. 129.14.6.8

If we see the first byte of the IP address which is 129, it belongs to class B as Class B ranges from 128 to 191.

10. In order to find the class of the IP addresses in easy way, start checking bit my bit from the left of the IP address and follow this pattern:

0 = Class A

1 - 0 = Class B

1 - 1 - 0 = Class C

1 - 1 - 1 - 0 = Class D

1 - 1 - 1 - 1 = Class E

a. 11110111 11110011 10000111 11011101

If we see the first four bits of the IP address they are 1111 which matches the pattern of class E given above. So this IP address belongs to class E.

b. 10101111 11000000 11110000 00011101

If we see the first bit is 1, the second bit is 0 which shows that this is class B address as 1 0 = Class B given above.

c. 11011111 10110000 00011111 01011101

The first bit is 1, second bit is 1 and third bit is 0 which shows this address belongs to class C as 110 = Class C given above.

d. 11101111 11110111 11000111 00011101

The first bit is 1, the second bit is also 1 and third bit is also 1 which shows that this address belongs to class D.

3 0
2 years ago
An aviation tracking system maintains flight records for equipment and personnel. The system is a critical command and control s
sergeinik [125]

Answer:

offline backup solution

Explanation:

In such a scenario, the best option would be an offline backup solution. This is basically a local and offline server that holds all of the flight record data that the cloud platform has. This offline backup server would be updated frequently so that the data is always up to date. These servers would be owned by the aviation company and would be a secondary solution for the company in case that the cloud platform fails or the company cannot connect to the cloud service for whatever reason. Being offline allows the company to access the database regardless of internet connectivity.

5 0
1 year ago
What protocol communicates data between routers representing the edges of autonomous systems?Distance-vectorLink stateInterior g
Nata [24]

Explanation:

Exterior gateway protocol are the routing protocols that are used on the internet for exchanging routing information among the autonomous system. These autonomous systems can be gateway protocol, vector routing protocol.

8 0
2 years ago
A regional bank implemented an automated solution to streamline their operations for receiving and processing checks/cheques. Th
Sphinxa [80]

Answer: Machine learning

Explanation:

The technology that could be combined with the current solution to do this is the machine learning.

Machine learning refers to the use and development of the computer systems which can learn and adapt without them following explicit instructions. This is done through the use of statistical models and algorithms in order to analyse inferences from the patterns in data.

Since the bank wants to streamline their operations for the receiving and processing checks while also enhancing the solution to recognize signs of potential check fraud, then the machine learning can be used.

3 0
1 year ago
Other questions:
  • What helps companies and organizations to target masses of people, provide 24/7 services, and deliver better marketing in a chea
    13·2 answers
  • Frequency of failure and network recovery time after a failure are measures of the _______ of a network.
    11·1 answer
  • PLEASE HELP!! WILL GIVE BRAINLIEST!!
    15·2 answers
  • List three functions that you can perform with a database that you cannot perform with a spreadsheet.
    11·1 answer
  • What is a typical grace period for a credit card...
    15·2 answers
  • Edward has started up a new company with his friend, Matthew. Currently, he has only two people working with him. Which type of
    8·1 answer
  • Your project must satisfy the following requirements:
    7·1 answer
  • Modify the closest pair of points algorithm so that the separating line L now separates the first n/4 points (sorted according t
    14·1 answer
  • Which of these tools can best be used as a self assessment for career planning purposes? a personality test an asset analysis a
    5·1 answer
  • 4.9 Code Practice: Question 4
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!