Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a Java question: We Pack N Ship 4 U packs and ships items using two kinds of containers: boxes and mailing tubes (cylinders).

I have a Java question: image text in transcribed
We Pack N Ship 4 U packs and ships items using two kinds of containers: boxes and mailing tubes (cylinders). Rates are determined by the size of the container. The size of a box is the sum of its three dimensions: length, width, and depth, in inches. For a mailing tube, with radius r inches and length l, size is calculated as 2pir + l. The cost of packing and shipping a box is $0.35 times the size of the cube. For a tube, the cost is $0.25 times the size of the container. Define an abstract class Container with a single instance variable, double length, two abstract methods, double getsize() and double getCost(), and one getter method double getLength(). Container should also implement Comparable based on cost. Next, create two subclasses of Container, Box and Tube, that implement getCost() and getSize(), where getCost() returns the cost of packing and shipping and getSize() returns the size of a container, as previously described. Box needs additional instance variables width and depth, and Tube requires radius. Include getter methods for Box and Tube. Finally, implement a TestContainer class that accepts 10 Container objects and stores them in an array. For each container, TestContainer should ask whether the container is a box or a tube and prompt for the appropriate dimensions. Sort the 10 containers in ascending order by cost. Print the type of container, the dimensions of the container, and the cost, rounded to two decimal places

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

Students also viewed these Databases questions