Write a program named TwoDArray with a two-dimensional integer array. The program asks user to enter...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program named TwoDArray with a two-dimensional integer array. The program asks user to enter number of rows and columns for the array, and then uses an object of class Random to fill out the array elements with some random integers between 1 and 100. The program should have the following methods: displayArray. This method should accept a two-dimensional array as its argument and print all values in the array. Each row in a separate line. .getRow Totals. This method should accept a two-dimensional array as its argument and print the total of the values in each row of the array in separate lines. getColTotals. This method should accept a two-dimensional array as its argument and print the total of the values in each column of the array in separate lines. .getRowHighest. This method should accept a two-dimensional array as its argument and print highest value in each row of the array in separate lines. .getColHighest. This method should accept a two-dimensional array as its argument and print highest value in each column of the array in separate lines. getAverage. This method should accept a two-dimensional array as its argument and print the average of all values in the array. After the program fills out the two-dimensional array with random numbers, it calls above methods in order Enter the number of rows: 3 Enter the number of columns: 4 Array elements: 16, 28, 94,73 27, 45, 34, 18 55, 23, 87,62 Total for row 1: 211 Total for row 2: 124 Total for row 3: 227 Total for column 1:98 Total for column 2: 96 Total for column 3: 215 Total for column 4: 153 Highest value in row 1:94 Highest value in row 2:45 Highest value in row 3: 87 Highest value in column 1:55 Highest value in column 2:45 Highest value in column 3: 94 Highest value in column 4: 73 Average of all values: 46.83 Write a program named TwoDArray with a two-dimensional integer array. The program asks user to enter number of rows and columns for the array, and then uses an object of class Random to fill out the array elements with some random integers between 1 and 100. The program should have the following methods: displayArray. This method should accept a two-dimensional array as its argument and print all values in the array. Each row in a separate line. .getRow Totals. This method should accept a two-dimensional array as its argument and print the total of the values in each row of the array in separate lines. getColTotals. This method should accept a two-dimensional array as its argument and print the total of the values in each column of the array in separate lines. .getRowHighest. This method should accept a two-dimensional array as its argument and print highest value in each row of the array in separate lines. .getColHighest. This method should accept a two-dimensional array as its argument and print highest value in each column of the array in separate lines. getAverage. This method should accept a two-dimensional array as its argument and print the average of all values in the array. After the program fills out the two-dimensional array with random numbers, it calls above methods in order Enter the number of rows: 3 Enter the number of columns: 4 Array elements: 16, 28, 94,73 27, 45, 34, 18 55, 23, 87,62 Total for row 1: 211 Total for row 2: 124 Total for row 3: 227 Total for column 1:98 Total for column 2: 96 Total for column 3: 215 Total for column 4: 153 Highest value in row 1:94 Highest value in row 2:45 Highest value in row 3: 87 Highest value in column 1:55 Highest value in column 2:45 Highest value in column 3: 94 Highest value in column 4: 73 Average of all values: 46.83
Expert Answer:
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
The classic MIPS 5-stage pipeline is depicted below. instruction decode and execute memory write fetch register fetch access back (i) With reference to the 5-stage pipeline, what are data hazards and...
-
Seth borrows X for ten years at an annual effective interest rate of 4%, to be repaid with equal payments at the end of each year. The outstanding loan balance at the end of the eighth year is...
-
A 0.8870-g sample of a mixture of NaCl and KCl is dissolved in water, and the solution is then treated with an excess of AgNO3 to yield 1.913g of AgCl. Calculate the percent by mass of each compound...
-
The comparative balance sheet of Navaria Inc. for December 31, 20Y3 and 20Y2, is as follows: The income statement for the year ended December 31, 20Y3, is as follows: Additional data obtained from an...
-
Consider the quadratic programming problem 1-Solve the problem using KKT conditions. 2-Observe that, if we could get rid of the first inequality, we could decompose the problem into two independent...
-
Selected accounts of Leno Company are shown below. InstructionsFrom an analysis of the T-accounts, reconstruct (a) The October transaction entries, (b) The adjusting journal entries that were made on...
-
You are evaluating a project that will require an initial investment of $200. Over the next four years, the project is expected to generate after-tax cash flows of 40, 50, 60, 70. If 8% is your...
-
Maya Company manufactures a product which sells for $20 each. Each unit of product has a variable cost of $5 to manufacture. Fixed costs normally incurred are $60,000. Maya Company is considering...
-
In a two-parameter Weibull distribution B > 1 represents an increasing MTTF a) > 1 represents a decreasing hazard rate b) B 9) B 1 represents an increasing MTTF d) < 1 represents an increasing hazard...
-
1 Describe your favourite consumer product 2) Outline the major global inputs to make that product such as raw materials, parts, labour, capital, etc. and tell from which countries these global...
-
A domestic corporation has the following data: Excess tax credits from 2020 For the year 2021: 15,000 1st gtr Income, net of 1% withholding tax 495,000 Deductions 460,000 How much is the income tax...
-
Joana Corporation realized an ordinary gain of 400,000. Its capital asset transactions during the year are as follows: Holding period Capital gain 6 month Capital gain 2 years Capital loss 12 months...
-
When it comes to being tasked with recruiting new marketing professionals, It is best to do an attractive compensation benefits package that includes competitive salaries, bonuses, and incentives. I...
-
Explain how different states have distinct political traditions.
-
The pendulum consists of two rods: AB is pin supported at A and swings only in the y-z plane, whereas a bearing at B allows the attached rod BD to spin about rod AB. At a given instant, the rods have...
-
Let \(\left(B_{t} ight)_{t \geqslant 0}\) be a \(\mathrm{BM}^{1}\) and denote by \(g_{t}\) the last zero before time \(t>0\). a) Use Theorem 11.25 to give a further proof of Lvy's arc-sine law (cf....
-
Let \(\left(B_{t} ight)_{t \geqslant 0}, d_{t}\) and \(g_{t}\) be as in Corollary 11.26. Define \[L_{t}^{-}:=t-g_{t} \quad \text { and } \quad L_{t}:=d_{t}-g_{t}\] Find the laws of \(\left(L_{t}^{-},...
-
Let \(\left(B_{t} ight)_{t \geqslant 0}\) be a \(\mathrm{BM}^{1}\). Apply Doob's maximal inequality (A.13) to the exponential martingale \(M_{t}^{\xi}:=\exp \left(\xi B_{t}-\frac{1}{2} \xi^{2} t...
Study smarter with the SolutionInn App