Create a class named Package with data field for weight in ounces, shipping method, and shipping costs. The shipping method is a character A for Air, T for Truck, or M for mail. The Package class contains a constructor that requires arguments for each weight and shipping method. The constructor class a calculatecost() method that determines the shipping cost based on the following table;

Weight Air Truck Mail
1-8 $2.00 $1.50 $0.50
9-16 $3.00 $2.35 $1.50
17+ $4.50 $3.25 $2.15


The Package class also contains a display () method that displays the values in all four fields. Create a subclass name InsuredPackage that adds insurance cost to the shipping cost based on the following table;

Shipping cost before Insurance Additional Cost
0 to 1.00 $2.45
1.01 to 3.00 $3.95
3.01 and over 5.55

Write an application named UsedPackage that instantiates at least 3 objects of each type (Package and Insurance) using a variety of weights and shipping methods codes. Display the results for each Package and InsurancePackage. Save the file as Package.java, InsuredPackage.java, and UsePackage.java

So? What do you have? We are not going to do your homework for you. Not only do we, personally, not support cheating, but it is also against the terms and agreements you agreed to when you signed up for an account here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.