Please Solve this by Java 14 Question 3 (10 points) - Capacity 10 Assume you have a
Fantastic news! We've Found the answer you've been seeking!
Question:
Please Solve this by Java
Transcribed Image Text:
14 Question 3 (10 points) - Capacity 10 Assume you have a class called MyObject. Complete the capacity method below to provide information about the current capacity of a given 2D array of MyObjects. The method should return an array of two ints, where the first is the number of objects filled in the array, and the second is the total number of objects that can fit in the array. You may assume the 2D array and its component arrays (because a 2D array is an array of arrays) are all initialized, but the 2D array may be ragged. Hint: A spot in a 2D array is not "filled" if there is no object assigned to that location, so if its value equals (--) null. public static int[] capacity (MyObject[][] arr) { int[] capInfo = new int[2]; } return capInfo; // For example: calls to capacity method (and the results returned) public static void main(String[] args) { MyObject[] [] arr1 = new MyObject [3] [4]; int[] capacityInfo capacity (arrl); System.out.println("arrl is at " + capacityInfo [0] + "/" + capacityInfo [1] + " capacity"); // prints "arrl is at 0/12 capacity" MyObject[] [] arr2 = new MyObject [2] []; arr2[0] = new MyObject[] {new MyObject() }; arr2[1] = new MyObject [5]; capacityInfo capacity (arr2); System.out.println("arr2 is at " + capacityInfo [0] + "/" + capacityInfo [1] + " capacity"); // prints "arr2 is at 1/6 capacity" } 14 Question 3 (10 points) - Capacity 10 Assume you have a class called MyObject. Complete the capacity method below to provide information about the current capacity of a given 2D array of MyObjects. The method should return an array of two ints, where the first is the number of objects filled in the array, and the second is the total number of objects that can fit in the array. You may assume the 2D array and its component arrays (because a 2D array is an array of arrays) are all initialized, but the 2D array may be ragged. Hint: A spot in a 2D array is not "filled" if there is no object assigned to that location, so if its value equals (--) null. public static int[] capacity (MyObject[][] arr) { int[] capInfo = new int[2]; } return capInfo; // For example: calls to capacity method (and the results returned) public static void main(String[] args) { MyObject[] [] arr1 = new MyObject [3] [4]; int[] capacityInfo capacity (arrl); System.out.println("arrl is at " + capacityInfo [0] + "/" + capacityInfo [1] + " capacity"); // prints "arrl is at 0/12 capacity" MyObject[] [] arr2 = new MyObject [2] []; arr2[0] = new MyObject[] {new MyObject() }; arr2[1] = new MyObject [5]; capacityInfo capacity (arr2); System.out.println("arr2 is at " + capacityInfo [0] + "/" + capacityInfo [1] + " capacity"); // prints "arr2 is at 1/6 capacity" }
Expert 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
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Let r and s be solutions to the quadratic equation x 2 b x + c = 0. For n N, define d0 = 0 d1 = r s dn = b dn1 c dn2 (n 2) Prove that dn = r n s n for all n N. [4 marks] (b) Recall that a commutative...
-
Which of the following domains are closed and which are bounded? (a) {(x, y) R: x + y 1} (b) {(x, y) = R: x + y <1} (c) {(x, y) = R: x 0} (d) {(x, y) R: x > 0, y > 0} (e) {(x, y) = R: 1 x 4,5 y 10}...
-
The mass spectrum and infrared spectrum of an unknown compound are shown in Figures 13.27 and 13.28, respectively. Identify the compound. Figure 13.27 The mass spectrum for Problem 28. 100 E 80 3 60...
-
If the odds in craps are 8-to-1 against rolling an 8 the hard way (that is, with two 4s), what is the expectation purchased by a $1 bet on a hard-way 8?
-
Many single women and married couples use donated sperm to conceive children each year. Pennsylvania resident Donna Donovan decided to use donated sperm from Idant Laboratories, a New York sperm bank...
-
Builder Products, Inc., manufactures a caulking compound that goes through three processing stages prior to completion. Information on work in the first department, cooking, is given below for May:...
-
Company EJ plans to build a new plant to manufacture bicycles. EJ sells its bicycles in the world market for $400 per bike. It could locate the plant in Province P, which levies a 20 percent tax on...
-
The quality assurance department at a hospital has as one of its responsibilities the verification of medical records. One of the department's employees samples medical records and checks each one...
-
Create a statechart with multiple orthogonal states (similar to that in Figure 5.6 ) for the elevator control system.
-
For an MA(2) model, the parameters have been estimated as 1 = 0. 8 and 2 = 0. 45. Check whether the parameters pass the invertibility condition.
-
How much economic rent will a talented chef get?
-
Construct a simple P&L statement like the one shown in exhibit 5.5 and discuss its elements. Exhibit 5.5 Total revenues ($100 75,000) $7,500,000 Total variable costs ($28.18 x 75,000) 2,113,500 Total...
-
What is the meaning of a four-firm concentration ratio of 60 percent? 90 percent?
-
Designing cross-cultural research: Locate a journal article that reports a psychological study conducted within a single culture. Adapt the procedures used in the published study for one youd like to...
-
Read Case Study Google: Dont Be Evil Unless and answer the following: Why do you think Google was adamant about not wanting to supply information requested by the government concerning the Child...
-
See Table 2.5 showing financial statement data and stock price data for Mydeco Corp. a. Compute Mydecos PE ratio each year from 2019 to 2023. In which year was it the highest? b. What was Mydecos...
-
See Table 2.5 showing financial statement data and stock price data for Mydeco Corp. a. Compute Mydecos ROE each year from 2019 to 2023. b. Compute Mydecos ROA each year from 2019 to 2023. c. Which...
-
In early 2018, United Airlines (UAL) had a market capitalization of \($25.14\) billion, debt of \($12.73\) billion, and cash of \($5.59\) billion. United also had annual revenues of \($38.72\)...
Study smarter with the SolutionInn App