Objective: Using the provided code (Box.java and Question03.java), write methods that returns the instances of boxes...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Objective: Using the provided code (Box.java and Question03.java), write methods that returns the instances of boxes that have the minimum and maximum weight of an array of boxes. Requirements: • Functionality. (20pts) . 。 No Syntax, Major Run-Time, or Major Logic Errors. (20pts*) ■ *Code that cannot be compiled due to syntax errors is nonfunctional code and will receive no points for this entire section. ■ *Code that cannot be executed or tested due to major run-time or logic errors is nonfunctional code and will receive no points for this entire section. ■ *In addition, this also applies to the provided code, which must not be modified where it states, "Do Not Alter". 。 Method getMaxWeight (5pts) ■This method must work with the provided code and must have the identifier "getMaxWeight”. ■ This method must not be given any values and must return the Box that has the heaviest weight from the array "boxes". ■ You may assume that the array "boxes" has been constructed before calling the method. ■ However, you may not assume every element of the array has been constructed. ■ If the array is empty, then the method must return null. ■ All must apply for full credit. 。 Method getMinWeight (5pts) ■ This method must work with the provided code and must have the identifier "getMinWeight”. ■This method must not be given any values and must return the Box that has the lightest weight from the array "boxes". ■ You may assume that the array "boxes” has been constructed before calling the method. ■ However, you may not assume every element of the array has been constructed. ■ If the array is empty, then the method must return null. ■ All must apply for full credit. 。 Method getTotalWeight (10pts) ■This method must work with the provided code and must have the identifier "getTotalWeight". ■ This method must not be given any values and must return a decimal value that corresponds to the total weight of the boxes in the array. ■ You may assume that the array "boxes” has been constructed before calling the method. ■ However, you may not assume every element of the array has been constructed. ■ If the array is empty, then the method must return 0. ■ All must apply for full credit. Coding Style. (2pts) 。 Readable Code ■ Meaningful identifiers for data and methods. ■ Proper indentation that clearly identifies statements within the body of a class, a method, a branching statement, a loop statement, etc. ■ All the above must apply for full credit. • Comments. (3pts) Testing get max and min methods The box with the minimum weight is: [Box] Label: Box09 Weight: 5.0 The box with the maximum weight is: [Box] Label: Box07 Weight: 50.0 The total weight is: 125.0 Resetting some of the Boxes, and testing the get max and min methods The box with the minimum weight is: [Box] Label: Box00 Weight: 4.0 The box with the maximum weight is: [Box] Label: Box08 Weight: 58.0 The total weight is: 206.0 Testing get min and max methods with an empty Array The box with the minimum weight is: null The box with the maximum weight is: null The total weight is: 0.0 /* * <<YOUR NAME>> CSCE 145 S2022 Exam02 Question03 *Provided code. Do not alter the code that says "Do not alter" * Make sure this at least compiles (no syntax errors) */ //Do not alter- public class Question 03 { //The array of boxes to be used by the methods. //This property is public for testing purposes public Box [] boxes; //Write the methods here // //Do not alter- public static void main(String[] args) { Box [] boxArray = new Box [10]; boxArray[0] = null; boxArray[1] = null; boxArray[2] = new Box("Box02", 10.0); boxArray [3] = new Box("Box03",20.0); boxArray[4] = null; boxArray[5] = new Box("Box05",40.0); boxArray [6] = null; boxArray[7] = new Box("Box07", 50.0); boxArray[8] = null; boxArray [9] = new Box("Box09",5.0); Question03 q3 = new Question03(); q3. boxes = boxArray; System.out.println("Testing get max, min, and total weight methods"); System.out.println("The box with the minimum weight is: "+q3.getMinWeight().getString()); System.out.println("The box with the maximum weight is: "+q3.getMaxWeight().getString()); System.out.println("The total weight is: "+q3.getTotalWeight()); ......... System Println("Resetting some of the Boxes, and testing the get max and min methods"); = new Box("Box00",4.0); boxArray[4] = new Box("Box04", 19.0); boxArray [8] = new Box ("Box08", 58.0); System.out.println("The box with the minimum weight is: "+q3.getMinWeight().getString()); System.out.println("The box with the maximum weight is: "+q3.getMaxWeight().getString()); System.out.println("The total weight is: "+q3.getTotalWeight()); System.out.println("Testing get min and max methods with an empty Array"); boxArray = new Box [10]; q3.boxes = boxArray; System.out.println("The box with the minimum weight is: "+q3.getMinWeight()); System.out.println("The box with the maximum weight is: "+q3.getMaxWeight()); System.out.println("The total weight is: "+q3.getTotalWeight()); } V* *CSCE 145 S2022 Exam02 Question03 Provided code. Do not alter the code that says "Do not alter" *Make sure this at least compiles (no syntax errors) *You may write additional methods to help */ //Do not alter--- public class Box { private String label; private double weight; public Box(String aL, double aw). { if(al != null) if(aw 0.0) this.label = aL; this.weight = aW; public String getLabel() { } return label; public double getWeight() { return weight; public String getString() } { } } //- return "[Box] Label: "+this.label+" Weight: "+this.weight; Objective: Using the provided code (Box.java and Question03.java), write methods that returns the instances of boxes that have the minimum and maximum weight of an array of boxes. Requirements: • Functionality. (20pts) . 。 No Syntax, Major Run-Time, or Major Logic Errors. (20pts*) ■ *Code that cannot be compiled due to syntax errors is nonfunctional code and will receive no points for this entire section. ■ *Code that cannot be executed or tested due to major run-time or logic errors is nonfunctional code and will receive no points for this entire section. ■ *In addition, this also applies to the provided code, which must not be modified where it states, "Do Not Alter". 。 Method getMaxWeight (5pts) ■This method must work with the provided code and must have the identifier "getMaxWeight”. ■ This method must not be given any values and must return the Box that has the heaviest weight from the array "boxes". ■ You may assume that the array "boxes" has been constructed before calling the method. ■ However, you may not assume every element of the array has been constructed. ■ If the array is empty, then the method must return null. ■ All must apply for full credit. 。 Method getMinWeight (5pts) ■ This method must work with the provided code and must have the identifier "getMinWeight”. ■This method must not be given any values and must return the Box that has the lightest weight from the array "boxes". ■ You may assume that the array "boxes” has been constructed before calling the method. ■ However, you may not assume every element of the array has been constructed. ■ If the array is empty, then the method must return null. ■ All must apply for full credit. 。 Method getTotalWeight (10pts) ■This method must work with the provided code and must have the identifier "getTotalWeight". ■ This method must not be given any values and must return a decimal value that corresponds to the total weight of the boxes in the array. ■ You may assume that the array "boxes” has been constructed before calling the method. ■ However, you may not assume every element of the array has been constructed. ■ If the array is empty, then the method must return 0. ■ All must apply for full credit. Coding Style. (2pts) 。 Readable Code ■ Meaningful identifiers for data and methods. ■ Proper indentation that clearly identifies statements within the body of a class, a method, a branching statement, a loop statement, etc. ■ All the above must apply for full credit. • Comments. (3pts) Testing get max and min methods The box with the minimum weight is: [Box] Label: Box09 Weight: 5.0 The box with the maximum weight is: [Box] Label: Box07 Weight: 50.0 The total weight is: 125.0 Resetting some of the Boxes, and testing the get max and min methods The box with the minimum weight is: [Box] Label: Box00 Weight: 4.0 The box with the maximum weight is: [Box] Label: Box08 Weight: 58.0 The total weight is: 206.0 Testing get min and max methods with an empty Array The box with the minimum weight is: null The box with the maximum weight is: null The total weight is: 0.0 /* * <<YOUR NAME>> CSCE 145 S2022 Exam02 Question03 *Provided code. Do not alter the code that says "Do not alter" * Make sure this at least compiles (no syntax errors) */ //Do not alter- public class Question 03 { //The array of boxes to be used by the methods. //This property is public for testing purposes public Box [] boxes; //Write the methods here // //Do not alter- public static void main(String[] args) { Box [] boxArray = new Box [10]; boxArray[0] = null; boxArray[1] = null; boxArray[2] = new Box("Box02", 10.0); boxArray [3] = new Box("Box03",20.0); boxArray[4] = null; boxArray[5] = new Box("Box05",40.0); boxArray [6] = null; boxArray[7] = new Box("Box07", 50.0); boxArray[8] = null; boxArray [9] = new Box("Box09",5.0); Question03 q3 = new Question03(); q3. boxes = boxArray; System.out.println("Testing get max, min, and total weight methods"); System.out.println("The box with the minimum weight is: "+q3.getMinWeight().getString()); System.out.println("The box with the maximum weight is: "+q3.getMaxWeight().getString()); System.out.println("The total weight is: "+q3.getTotalWeight()); ......... System Println("Resetting some of the Boxes, and testing the get max and min methods"); = new Box("Box00",4.0); boxArray[4] = new Box("Box04", 19.0); boxArray [8] = new Box ("Box08", 58.0); System.out.println("The box with the minimum weight is: "+q3.getMinWeight().getString()); System.out.println("The box with the maximum weight is: "+q3.getMaxWeight().getString()); System.out.println("The total weight is: "+q3.getTotalWeight()); System.out.println("Testing get min and max methods with an empty Array"); boxArray = new Box [10]; q3.boxes = boxArray; System.out.println("The box with the minimum weight is: "+q3.getMinWeight()); System.out.println("The box with the maximum weight is: "+q3.getMaxWeight()); System.out.println("The total weight is: "+q3.getTotalWeight()); } V* *CSCE 145 S2022 Exam02 Question03 Provided code. Do not alter the code that says "Do not alter" *Make sure this at least compiles (no syntax errors) *You may write additional methods to help */ //Do not alter--- public class Box { private String label; private double weight; public Box(String aL, double aw). { if(al != null) if(aw 0.0) this.label = aL; this.weight = aW; public String getLabel() { } return label; public double getWeight() { return weight; public String getString() } { } } //- return "[Box] Label: "+this.label+" Weight: "+this.weight;
Expert Answer:
Answer rating: 100% (QA)
Boxjava Boxjava This class simply represents a model of a Box with attributes labelString and weightDouble author YOURNAME version 10 since 06042021 public class Box instance variables private String ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Technology World tsad the following revenue and expenses during the month ended July 31, Fees for computer repairs Advertising expense Salaries expense Telephone expenses fees for printer repairs...
-
The following data for Flexco Inc. relate to the payroll for the week ended December 9, 20Y8: Employees Grove and Seaver are office staff, and all of the other employees are sales personnel. All...
-
Multiple Choice Questions 1. As a result of a stock split, a. Stockholders equity is increased. b. The par value of the stock is changed in the reverse proportion as the stock split. c. The...
-
A 5. 0-kg block suspended from a spring scale is slowly lowered onto a vertical spring (Figure P8.94). (a) What does the scale read before the block touches the vertical spring? (b) If the scale...
-
Mac Ericson and Tammy Ferguson met at an IMA conference two months ago and began dating. Mac is the controller for Longley Enterprises, and Tammy is a marketing manager for Sharp Products. Longley is...
-
The first thing is to load the MNIST data into our Machine Learning programs. We will set up the digitClassifier.py to expect input as two matrices: (i) the set of training images X and (ii) the set...
-
The masses (in grams) of a sample of a species of fish caught in the waters of a region are shown below. 18.2 17.7 17.3 17.9 18.9 17.8 21.7 22.7 21.7 Determine whether the data are qualitative or...
-
http://public.tepper.cmu.edu/ethics/AA/mgmt02-case.pdf What Are the Ethical Issues? 1. To what extent is it Kirk's responsibility to take any actions? 2. How can the interests of the firm and its...
-
1.Creating a tip sheet that can be use in the future that will help when developing client recommendations to improve their digital marketing strategies.It should cover a wide range of digital...
-
What is the impact or effect of the changing floor plan or remodeling in hospital without consideration to all aspect of technical utility operational and behavioral element. Kindly explain in...
-
Company XYZ pays no dividends for the next seven years. In year 8, the dividend is expected to be D8 $20, and in subsequent years, annual dividend growth will be 9 = 4%. The discount rate is r = 6%....
-
Evaluating personnel can be difficult in the criminal justice system. An employee interacts with both internal and external individuals, so their impact is large. How can a department/supervisor...
-
Water is being heated in a closed pan on top of a range while being stirred by a paddle wheel. During the process, 35 kJ of heat is transferred to the water, and 5 kJ of heat is lost to the...
-
Determine the center and radius of each circle. Sketch each circle. 4x 2 + 4y 2 9 = 16y
-
Steve Jackson (age 51) is a single taxpayer living at 3215 Pacific Dr., Del Mar, CA 92014. His Social Security number is 465-88-9415. In 2012, Steve's earnings and income tax withholding as the...
-
Carl Conch and Mary Duval are married and file a joint return. They live at 1234 Mallory Sq. Apt. 64, Key West, FL 33040. Carl works for the Key Lime Pie Company and Mary is a homemaker after losing...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family. Ivan and Irene have the following investment income, in addition to that reported in Chapter 1: Dividends...
-
A child on a sled slides down an icy slope, starting at a speed of \(2.5 \mathrm{~m} / \mathrm{s}\). The slope makes a \(15^{\circ}\) angle with the horizontal. After sliding \(10 \mathrm{~m}\) down...
-
A particle is accelerated such that its position as a function of time is given by \(\vec{x}=b t^{3} \hat{t}\), with \(b=1.0 \mathrm{~m} / \mathrm{s}^{3}\). What is the particle's acceleration as a...
-
You hold a puck at the top of an ice-covered ramp inclined at \(60^{\circ}\) with respect to the vertical. Your friend stands nearby on level ground and holds a ball at the same height \(h\) above...
Study smarter with the SolutionInn App