In this problem, we are dealing with packaging boxes. You will need to create three classes...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
class RegularBox private double length width height private String material public RegularBoxdouble ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
In this assignment, you will create a program that allows theuser to draw in a window using brushes of different sizes andcolors. The user will be able to change the size and color of thebrush using...
-
Trans World Publishing Inc. was recently organized. The company issued common shares to a lawyer who provided legal services of $15,000 to help organize the corporation. Trans World also issued...
-
What is the output of the following App? 1 point public class Three Int { int int1 = 5; int int2 = 7; int int3 = 4; public String toString() { } return int3 + "," + intl + ", and" + int2; public...
-
When a discovery motion may be necessary?
-
Assume that on January 2, 2012, Barrett of Nebraska purchased fixtures for $8,200 cash, expecting the fixtures to remain in service for five years. Barrett has depreciated the fixtures on a...
-
Apple is planning to incorporate new software for the price of $ 5 0 0 0 0 0 today in order to produce a new line of the iPod. The new iPod will be ready for sale in 1 year. If the new software will...
-
The comparative balance sheet of Iglesias Inc. for December 31, 20Y3 and 20Y2, is as follows: Additional data obtained from an examination of the accounts in the ledger for 20Y3 are as follows: a....
-
Ann was very keen to know the contents of the report written by her supervisor about her performance. The supervisor had sent the report to John, the head of HR, by email. Luckily Ann was able to...
-
1. Which statement by a nurse reflects an accurate understanding of systems theory? a.My patient has anemia reflected by low RBC, Hgb, and Hct values, so I have to monitor for fatigue, dyspnea, and...
-
The following article will be used in the case study and the individual test. Make sure you read this article (carefully) when preparing for the case study. Uranium price breaches US$60 a pound as...
-
A sprinkler system with control mode design area ceiling sprinklers and in-rack sprinklers is protecting a storage warehouse for Group A plastics stored up to 20-ft in height. A separate cross main...
-
We all pay attention to reviews - both good and bad. A survey of TripAdvisor users has revealed that online reviews remain a trusted source of information when booking trips. For accommodation...
-
News Corp has been heavily criticised by investors and fund managers for both large bonuses paid to executives, and its focus on short-term performance. The company recently restructured its...
-
Norma Rae Movie Quesitons 1. What kind of labor relations strategy is present here? 2. Explain the ethics of the Henley Textile Mill. 3. How do you explain the attitude of the national unionregarding...
-
In Exercises 105108, evaluate each expression without using a calculator. log(ln e)
-
As a model for the production of trypsin for trypsinogen in digestion, biochemists have proposed the model dy/dt = k(A - y) (B+y) Where k> 0, A is the initial amount of trypsinogen, and B is the...
-
Find the equation of the parabola through the point (-2, 4) if its vertex is at the origin and its axis is along the x-axis. Make a sketch.
-
In Problems 1-4, se a CAS to plot of the parametric surface over the indicated domain and find the surface area of the resulting surface? 1. r(u, v) = u sin v i + u cos u j + u k; - 6 ( u ( 6, 0 ( u...
-
(a) Explain why quality control may be difficult to implement in a smaller audit firm and illustrate how such difficulties may be overcome. (b) Kite Associates is an association of small accounting...
-
Angela Goodbody is a partner in Tickitt & Run and has come to the audit of E-musica Ltd to carry out a hot review of the audit which is in progress for the year ended 31 March 2X11. E-musica have...
-
Your firm is the external auditor of Octavia Ltd (Octavia). The team conducting the audit for the year ended 31 December 2X10 has recently returned to the office following completion of the audit...
Study smarter with the SolutionInn App