write the Java programs that use methods and two-dimensional arrays. Problem 1: Complete the following java...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
write the Java programs that use methods and two-dimensional arrays. Problem 1: Complete the following java program which creates a two-dimensional array of 36 (6 X 6) elements. The program then should do the following: 1. Initialize the elements of the array to random numbers between 0 and 100. 2. Display the content of the array in the form of a matrix. 3. Display the sum of elements of the array by columns. 4. Find and display the column number that has the largest sum. 5. Calculate and display the average of all the numbers. 6. Display the smallest element and its location in the array. public class MultiDimensionalArrayDemo { } public static void main(String[] args) { int[][] numbers = new int [6] [6]; int column = 0; initializeArray (numbers); System.out.println("The two-dimensional array of 6 by 6 random numbers is:"); displayArray (numbers); System.out.println("The sum of elements of the array by columns is: "); System.out.println(); int[] colsum = SumByColumn(numbers); //displaying the sum of elements by columns for(int i: colsum) { System.out.printf("%d", 1); } System.out.println(); System.out.println(); column colwith Largestsum(colsum); System.out.println("The column column has the largest sum of colsum[column]); System.out.printf("\nThe average of the array elements is %.2f \n\n", getAverage (numbers)); displaySmallestAnd Location (numbers); Sample Outputs: The two-dimensional array of 6 by 6 random numbers is: 43 12 67 9 22 45 72 8 65 95 80 75 98 82 26 35 19 45 3 74 69 58 10 39 4 84 5 4 93 40 9 34 94 98 71 45 The sum of elements of the array by columns is: 430 261 277 204 173 387 The column e has the largest sum of 430 The average of the array elements is 48.11 The smallest element is 3 and is located in row 2 and column 3 84 83 83 79 67 27 The two-dimensional array of 5 by 6 random numbers is: 42 69 34 95 37 76 1 20 27 1 82 12 79 59 14 2 97 29 97 96 93 63 56 98 17 25 9 1 71 1 The sum of elements of the array by columns is: 347 340 482 298 220 139 The column 2 has the largest sum of 482 The average of the array elements is 50.72 The smallest element is 1 and is located in row 3 and column 1 Hand In: • Make a folder named lab7_yourname containing the source code file, zip the folder and submit the zipped file to BrightSpace. Rubrics: Program: [2 marks] Presentation and Style: Readability, descriptive identifier, indentation, bracket placement, internal documentation (comments), use of appropriate constants • [18 marks] Correctness: Program works without bugs write the Java programs that use methods and two-dimensional arrays. Problem 1: Complete the following java program which creates a two-dimensional array of 36 (6 X 6) elements. The program then should do the following: 1. Initialize the elements of the array to random numbers between 0 and 100. 2. Display the content of the array in the form of a matrix. 3. Display the sum of elements of the array by columns. 4. Find and display the column number that has the largest sum. 5. Calculate and display the average of all the numbers. 6. Display the smallest element and its location in the array. public class MultiDimensionalArrayDemo { } public static void main(String[] args) { int[][] numbers = new int [6] [6]; int column = 0; initializeArray (numbers); System.out.println("The two-dimensional array of 6 by 6 random numbers is:"); displayArray (numbers); System.out.println("The sum of elements of the array by columns is: "); System.out.println(); int[] colsum = SumByColumn(numbers); //displaying the sum of elements by columns for(int i: colsum) { System.out.printf("%d", 1); } System.out.println(); System.out.println(); column colwith Largestsum(colsum); System.out.println("The column column has the largest sum of colsum[column]); System.out.printf("\nThe average of the array elements is %.2f \n\n", getAverage (numbers)); displaySmallestAnd Location (numbers); Sample Outputs: The two-dimensional array of 6 by 6 random numbers is: 43 12 67 9 22 45 72 8 65 95 80 75 98 82 26 35 19 45 3 74 69 58 10 39 4 84 5 4 93 40 9 34 94 98 71 45 The sum of elements of the array by columns is: 430 261 277 204 173 387 The column e has the largest sum of 430 The average of the array elements is 48.11 The smallest element is 3 and is located in row 2 and column 3 84 83 83 79 67 27 The two-dimensional array of 5 by 6 random numbers is: 42 69 34 95 37 76 1 20 27 1 82 12 79 59 14 2 97 29 97 96 93 63 56 98 17 25 9 1 71 1 The sum of elements of the array by columns is: 347 340 482 298 220 139 The column 2 has the largest sum of 482 The average of the array elements is 50.72 The smallest element is 1 and is located in row 3 and column 1 Hand In: • Make a folder named lab7_yourname containing the source code file, zip the folder and submit the zipped file to BrightSpace. Rubrics: Program: [2 marks] Presentation and Style: Readability, descriptive identifier, indentation, bracket placement, internal documentation (comments), use of appropriate constants • [18 marks] Correctness: Program works without bugs
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
-
. Do policies exist within the Linux workstation or server environment? If so, what are they? . Are there ways that Windows policies can be leveraged to enhance corporate or security policy?
-
Here is a question from the web that shows the type of problem you might encounter inreal life: I am trying to solve the following partitioned linear system, where each letter represents a block -H...
-
(10) Let A be a linear transformation of Rn with the standard inner product xiyi. Prove that Ker (AA) Ker(A). (Hint: recall first what does it mean that = x Ker(B) for a linear operator B and then...
-
Write a program that takes the name of a .wav file and a playback rate r as command-line arguments and plays the file at the given rate. First, use StdAudio.read() to read the file into an array a[]....
-
A plate in the shape of a parallelogram is acted upon by two couples. Determine (a) The moment of the couple formed by the two 21-N forces, (b) The perpendicular distance between the 12-N forces if...
-
Nitrogen gas flowing in a pipe at 500 kPa, 200C, and at a velocity of 10 m/s, should be expanded in a nozzle to produce a velocity of 300 m/s. Determine the exit pressure and cross-sectional area of...
-
You have made an appointment with a new potential customer. As you prepare for the presentation you realize this person has never purchased this kind of product before. What do you do?
-
Redraft the following issues in the format presented in this chapter. Part A Can a bystander who witnesses the death of a victim from three blocks away recover for negligent infliction of emotional...
-
-1 0 1 b. Open Gain A = V/V 8. Draw the transfer function curve of Vo versus Vdiff of an op-amp, where Vdiff - V+ V_, for the following cases. Sweep V diff from -1V to +1V. Rails are -1V to +1V. a....
-
Explain how you would determine how much profit was generated from orders placed in April 2009. Figure 1-5: ORDERS Order# Customer# Orderdate Shipdate Shipstreet Shipcity Shipstate Shipzip Shipcost...
-
The following balances were extracted from the books of XYZ LTD, a manufacturing firm in Ghana on December 31, 2021. Profit before tax . Depreciation of furniture . . . . . Depreciation of motor...
-
Now determine the Ending Finished Goods Inventory. Beginning finished goods inventory 4400 16300 Cost of goods manufactured Cost of goods available for sale 20700 Ending finished goods inventory Cost...
-
How does the dynamic viscosity of a non-Newtonian fluid, characterized by its dependence on shear rate and time, influence the flow behavior and resistance within complex geometries, and what...
-
Describe the importance of Vocal and Physical delivery. Public communication
-
1)what the need for RCSA policies and the importance of RCSAs with information security as a focal point. 2)a list that explains the relevance of RCSA policies. Provide references.
-
When should an expenditure be recorded as an asset rather than an expense?
-
George buys a car by carefully weighing all the options about the fuel consumption, performance, safety features, price, etc. This is an example of ________.
-
The vapor pressure of the liquid NH, is measured at different temperatures. The following vapor pressure data are obtained. Temperature, K P, mmHg 217.1 223.4 234.7 588.1 Calculate the enthalpy of...
-
Mark owns his home and has a $250,000 mortgage related to his purchase of the residence. When his daughter went to college in the fall of 2012, he borrowed $20,000 through a home equity loan on his...
-
Ken (age 31) and Amy (age 28) Booth have brought you the following information regarding their income, expenses, and withholding for the year. They are unsure which of these items must be used to...
-
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 project under consideration has a 10-year projected life. The initial investment for the project is estimated to have a mean of \(\$ 10,000\) and a standard deviation of \(\$ 1,000\). The annual...
-
True or False: In determining the optimum replacement interval, it is necessary to assume negligible salvage values.
-
Uncertainty can impact many elements of an engineering economic analysis. Given the list of factors below, rank them from most to least uncertain, and briefly justify why you ranked them in that...
Study smarter with the SolutionInn App