Determine the output of the following Java program, placing the output on the lines below exactly...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Determine the output of the following Java program, placing the output on the lines below exactly as it would appear on the terminal window. (Hint: first figure out what each of the methods f (). g() and h() do, then put the pieces together.) // Problem3.java class Problem3 { } public static void main(String[] args) { int[] A = (2, 4, 5); int[] B = [5, 3, -3); int[] [] T = g (A, B); System.out.println (f (A, B)); h (T); } static int f(int[] X, int[] x) { int i, sum = 0; for (i=0; i<x.length; i++) { sum += X[1] *Y[i]; } return sum; } static int[] [] g(int[] X, int[] y) { int[] [] M = new int [X.length] [Y. length]; for (int i=0; i<x.length; i++) for (int j = 0; j<Y.length; j++) M[1] [j] = X[1] *Y[j]; return M; static void h(int[] [] M) { for (int i=0; i<M.length; i++) { for (int j = 0; j<M[1].length; j++) System.out.print (M[i][j]+" "); System.out.println(); Determine the output of the following Java program, placing the output on the lines below exactly as it would appear on the terminal window. (Hint: first figure out what each of the methods f (). g() and h() do, then put the pieces together.) // Problem3.java class Problem3 { } public static void main(String[] args) { int[] A = (2, 4, 5); int[] B = [5, 3, -3); int[] [] T = g (A, B); System.out.println (f (A, B)); h (T); } static int f(int[] X, int[] x) { int i, sum = 0; for (i=0; i<x.length; i++) { sum += X[1] *Y[i]; } return sum; } static int[] [] g(int[] X, int[] y) { int[] [] M = new int [X.length] [Y. length]; for (int i=0; i<x.length; i++) for (int j = 0; j<Y.length; j++) M[1] [j] = X[1] *Y[j]; return M; static void h(int[] [] M) { for (int i=0; i<M.length; i++) { for (int j = 0; j<M[1].length; j++) System.out.print (M[i][j]+" "); System.out.println();
Expert Answer:
Answer rating: 100% (QA)
There are several issues in the provided Java code including syntax errors and undefined variables I ... 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
-
Sara got a cheque of HBL Lahore from Sadia, so she deposited it in her own account at Meezan Bank in Lahore. What is the process by which Meezan will send the cheque to HBL for funds collection?...
-
Declare and assign these variables as shown (all your code must appear in the body of the main method): String firstName = "Blueberry"; String lastName = "Strawberry"; In addition, declare and...
-
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...
-
While emptying a wheelbarrow, a gardener exerts on each handle AB a force P directed along line CD. Knowing that P must have a 30-lb horizontal component, determine (a) The magnitude of the force P,...
-
On what sector is manufacturing least dependent? Suppose that a simplified economy consisting of the three sectors Manufacturing, Energy, and Services has the input-output matrix 3 .25 .15 = A. .2]...
-
During the third calendar quarter of 20--, the Beechtree Inn, owned by Dawn Smedley, employed the persons listed below. Also given are the employees' salaries or wages and the amount of tips reported...
-
What is a vibration absorber?
-
York Industries leases a large specialized machine to Echo Company at a total rental of $1,400,000, payable in five annual installments in the following declining pattern: 24% in the first two years,...
-
Physical Units Beginning WIP 191 New units started 463 Ending WIP 56 *Beginning WIP was 100% complete for direct materials, and 40% complete for conversion costs **Ending WIP was 100% complete for...
-
Carrie D'Lake, Reed A. Green, and Doug A. Divot share a passion for golf and decide to go into the golf club manufacturing business together. On January 2, 2015, D'Lake, Green, and Divot form the...
-
What is the marginal revenue from producing the fourth unit? What is the marginal cost of producing the third unit? How many units should the profit maximizing firm produce? What is the average cost...
-
Why are males more delinquent than females? Is it a matter of lifestyle, culture, or physical properties?
-
Do you believe that self-reports are an accurate method of gauging the nature and extent of delinquentbehavior?
-
Are girls the victims of unfairness at the hands of the justice system, or do they benefit from chivalry?
-
Have you ever perceived anomie? What causes anomie? Is there more than one cause of strain?
-
The writer has a mass (measured by the scale) of \(73 \mathrm{~kg}\). Assuming the Earth's radius doubles, determine (i) my weight if \(M_{T}\) remained constant, and (ii) if the Earth's density...
-
A distribution of data is shown in the figure given below. Frequency 2 0 1 2 3 4 5 6 7 8 Y Select the mean and median of the sample from the option given below? (a) Mean(Y) = 2.0, Median(Y) = 2.5 (b)...
-
Consider the circuit of Fig. 7.97. Find v0 (t) if i(0) = 2 A and v(t) = 0. 1 3 ett)
-
Ray and Maria Gomez have been married 3 years. They live at 1610 Quince Ave., McAllen, TX 78701. Ray works for Palm Oil Corporation and Maria works for the City of McAllen. Maria's Social Security...
-
Mary paid $2,000 of state income taxes in 2012. The total sales tax she paid during 2012 was $5,500, which included $3,000 for the cost of a new car. How should Mary treat the taxes paid on her 2012...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Ronald Ondeyko, CPA, is considering the LaSalle Company's internal controls over investments, long-term debt, and capital stock. System documentation was accomplished with a questionnaire and a...
-
Following are errors, frauds, or other circumstances that an auditor might encounter as a result of applying audit tests to long-term debt as of the balance sheet date: a. Detailed long-term debt...
-
Following are errors, frauds, or other circumstances that an auditor might encounter as a result of applying audit tests to capital stock as of December 31, the balance sheet date: a. Shareholders'...
Study smarter with the SolutionInn App