Question: In this problem, we are dealing with packaging boxes. You will need to create three classes (all in the same file please, for ease

In this problem, we are dealing with packaging boxes. You will needto create three classes (all in the same file please, for ease

In this problem, we are dealing with packaging boxes. You will need to create three classes (all in the same file please, for ease of grading): 1. A RegularBox class (do not declare as public) 2. A SquareBox class (do not declare as public) 3. A Package Test class (this class is public and contains main()) The RegularBox class Four fields: length, width, height of the box (doubles), and the material for the box (paper, plastic, or wood). A full constructor ( you can assume there will be no silly inputs, e.g., length < 0) All the get methods (no need for set methods) A toString() method A getPackageVolume() method A getPackageCost() method. The cost is: O O O O $0.045 per cubic inch of volume for a carton box $0.0775 per cubic inch of volume for a plastic box $0.135 per cubic inch of volume for a wooden box The method returns -1 for any other material The SquareBox class This class inherits from the RegularBox class. It contains no fields and only one two methods: 1. A constructor: public SquareBox(double side, String material) 2. A getPackage Cost() method. Because of the square shape, the cost of such a box is 10% less than the cost of a regular box, given the same material. This method a. Must override its parent class method b. Must leverage the parent's class method code (NO code duplication!) The PackageTest class This is the public class containing the main() method to test the other two classes. Sample Run: // These two boxes have the same volume but one is square, the other is not! RegularBox regBox1 = new RegularBox(4, 8, 2, "carton"); SquareBox sqBox1 = new SquareBox(4, "carton"); RegularBox regBox2= new RegularBox(4, 8, 2, "plastic"); RegularBox regBox3 = new RegularBox(4, 8, 2, "wood"); SquareBox sqBox2= new SquareBox(3, "concrete"); // Your print statements here (see the desired output below: // All values to 2 decimal places. Output: The volume of regBox1 is 64.00 cubic inches The cost of regBox1 is $2.88 The cost of regBox2 is $4.96 The cost of regBox3 is $8.64 The cost of sqBox1 is $2.59 The cost of sqBox2 is $-1.00

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

class RegularBox private double length width height private String material public RegularBoxdouble ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!