public class Q1Test { public static void main(String[] args) { Integer[][] matrix0 =
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In Question 1, you develop a static method named sumRows that takes a two-dimensional array (matrix) of Integer objects and returns a one-dimensional array of Integer objects. Each element in the returned array is the sum of the elements of the corresponding row in the input matrix. public class IntegerUtil ( public static Integer [] sumRows (Integer [][] matrix) { } if (matrix null) { return null; // All the code that you write for Question 1 goes here! The behaviour of sumRows(...) is illustrated in the figure below. As shown in the figure, the input matrix may have null values. Any null value should be treated as a zero (0) during summation. sumRows (1 02 1 2 3 0 103 1 2 3 1 1 1 sumRows null 2 1 [6 33 54] 2 3 0 1 null 3 null values are treated as zeros when computing the row sums. To test your implementation of sumRows(...), use the Q1Test.java in the template code provided to you. The output of running Q1Test should be as follows: $ java Q1Test Result for matrix: null Result for matrix1: [1] Result for matrix2: [6] Result for matrix3: [6, 6, 6, 6, 6, 6, 6, 6, 6] Result for matrix4: 28, 32," '211 Result for matrix5: [0] Result for matrix6: [0, 0] Result for matrix7: [4, 3, 5, 1, 2, 3] Result for matrix8: [25, 20, 17] Result for matrix9: [1, 0, 1, 1] $ Important Restrictions for Question 1 You cannot import anything at all. You cannot use any class other than the ones provided. You cannot declare any class or instance variables in IntegerUtil.java. All your variables should be local variables in the sumRows(...) method. QI Files IntegerUtil.java (you need to update this file) Q1Test.java In Question 1, you develop a static method named sumRows that takes a two-dimensional array (matrix) of Integer objects and returns a one-dimensional array of Integer objects. Each element in the returned array is the sum of the elements of the corresponding row in the input matrix. public class IntegerUtil ( public static Integer [] sumRows (Integer [][] matrix) { } if (matrix null) { return null; // All the code that you write for Question 1 goes here! The behaviour of sumRows(...) is illustrated in the figure below. As shown in the figure, the input matrix may have null values. Any null value should be treated as a zero (0) during summation. sumRows (1 02 1 2 3 0 103 1 2 3 1 1 1 sumRows null 2 1 [6 33 54] 2 3 0 1 null 3 null values are treated as zeros when computing the row sums. To test your implementation of sumRows(...), use the Q1Test.java in the template code provided to you. The output of running Q1Test should be as follows: $ java Q1Test Result for matrix: null Result for matrix1: [1] Result for matrix2: [6] Result for matrix3: [6, 6, 6, 6, 6, 6, 6, 6, 6] Result for matrix4: 28, 32," '211 Result for matrix5: [0] Result for matrix6: [0, 0] Result for matrix7: [4, 3, 5, 1, 2, 3] Result for matrix8: [25, 20, 17] Result for matrix9: [1, 0, 1, 1] $ Important Restrictions for Question 1 You cannot import anything at all. You cannot use any class other than the ones provided. You cannot declare any class or instance variables in IntegerUtil.java. All your variables should be local variables in the sumRows(...) method. QI Files IntegerUtil.java (you need to update this file) Q1Test.java
Expert Answer:
Related Book For
Java How To Program Early Objects
ISBN: 9780134743356
11th Edition
Authors: Paul Deitel, Harvey Deitel
Posted Date:
Students also viewed these programming questions
-
Project Goals In this project, you will be developing a simple Java application (texttool) using an agile, test-driven process involving multiple deliverables. While you will receive one grade for...
-
How do you simplify the max method in the following, using the conditional operator? 1: /** Return the max of two numbers */ 2: public static int max ( int num1, int num2 ) { 3: int result; 4: 5: if...
-
In the 1D Arrays Unit, you created a command-line Contact Manager v1. Now upgrade the software to include a graphic user interface. Your contact manager must: Have a menu bar that provides access to...
-
Papas Fried Chicken bought equipment on January 2, 2013, for $ 39,000. The equipment was expected to remain in service for four years and to perform 11,000 fry jobs. At the end of the equipments...
-
A firefighter is trying to hold a fire hose steady while spraying water. If the jet of water ( = 997 kg/m3) is coming from the 6.5-cm diameter fire hose at 400 GPM (0.025 m3/s), what is the force...
-
You are considering a project that requires a capital investment of $100 and will last for three years. Economical depreciation is straight line over 3 years (33.3% in each of the 3 years)) while tax...
-
Let \(q(t)\) be the survival probability and let \(q^{-1}\) be its inverse function. Also, let \(U\) be a uniform random variable on \([0,1]\). For each realization \(u\), let \(\tau\) be chosen such...
-
Mohammad Hashmi, a citizen of Pakistan, entered the United States in 2002 on a student visa. Two years later, when he applied for a job at CompuCredit, he completed an I-9 form and checked the box to...
-
ed -k 3 t inces The following information is from Princeton Company's comparative balance sheets. At December 31 Common stock, $10 par value Current Year $ 117,000 Paid-in capital in excess of par...
-
Prepare a material balance and a qualitative flow sheet for the production of 7800 kg/h of acetaldehyde using the process described in the previous problem. Assume an operating factor of 90 percent...
-
Hide Transcribed Text Seasonality or seasonal variation is typically caused by factors related to 1. weather, holiders and cuatoms of people 2.economic conditions such as the "business crele" 3....
-
Identify one of the historical researchers who have been instrumental in advancing the related sciences of Job Design and Work Measurement. After studying his or her research and the impact of the...
-
Scenario To reach sustainable success, business leaders need to disrupt their business continuously. Thus, for companies to stay competitive, they must integrate a culture that embraces technology,...
-
Managers have selected data collection strategies based on the research design. To understand customer satisfaction, a call center manager might use a qualitative research design or a quantitative...
-
Analyze different leadership theories and leadership styles. PATH GOAL theory and leadership style, and explain how they each support a professional nurse leader or individual in nursing leadership...
-
Summarize the Association of Government Accountants comments on AICPA Standards for Performing and Reporting on Peer Reviews.
-
You have just begun your summer internship at Omni Instruments. The company supplies sterilized surgical instruments for physicians. To expand sales, Omni is considering paying a commission to its...
-
When asked to make a choice, most people prefer \(\$ 2400\) with certainty to a lottery in which they may win \(\$ 2500\) with probability 0.33 , \(\$ 2400\) with probability 0.66 , and nothing with...
-
Consider the following two choices: 1. You have to choose between losing \(\$ 7400\) for sure, and a risky alternative, whereby you lose \(\$ 10,000\) with probability 0.75 and nothing with...
-
You are analyzing three stock shares: Joint, Eppon, and Peculiar Motors. Based on your analysis, the price of a Joint stock share should be the same as the sum of one Eppon share and one Peculiar...
Study smarter with the SolutionInn App