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[]....
-
The energy gap Eg in germanium is 0.72 eV. When used as a photon detector, roughly how many electrons can be made to jump from the valence to the conduction band by the passage of an 830-keV photon...
-
Calculate Minnies marginal revenue schedule and draw a graph of the market demand curve and Minnies marginal revenue curve. Explain why Minnies marginal revenue is less than the price. Minnies...
-
A business had always made a provision for doubtful debts at the rate of 5% of debtors. On 1 January 19X7 the provision for this, brought forward from the previous year, was 260. During the year to...
-
Complete the balance sheet of Flying Roos Corporation. You have the following information: Debt ratio = 40% DSO = 39 days Current ratio = 1.5 Inventory turnover ratio = 3.375 Sales = $2.25 million...
-
Execon Pty Ltd is a business that sells computer parts and systems. Due to the economic damage caused by Covid-19, Execon's sales have plummeted. Once a highly profitable business, their position has...
-
The following Tableau Dashboard shows a Snakey Chart for Rumors Coffee Inc, a local coffee shop in the Midwest. Rumors Coffee Inc. pays for its expenditures using three sources of capital; cash,...
-
Consider the following fund (answer Q1 & Q5): Time 0 Net cash flow ($ millions) HPR (%) Compute the Arithmetic return (simple average): -5 1 1 -6% 2 -1 6% 3 -1 9% 4 6.68 5%
-
Which of the 12 guidelines for creating incentive systems is the most important in your mind? Why did you choose this one?
-
_____ are extra financial benefits usually provided to top employees in many businesses.
-
One problem with using the same audit questionnaire on a routine basis is the problem of "cheating." Explain briefly.
-
_____ provide executives who are dismissed from a merged or acquired firm with typically large lump sum payments on dismissal.
-
Give three problems of mail questionnaires. Outline some techniques that auditors can use to overcome these problems when they employ mail questionnaires during the conduct of an audit.
-
Rosnan Industries' 2 0 1 7 and 2 0 1 6 balance sheets and income statements are shown below. All of the balance of Cash and Equivalents is an operating asset. Balance Sheets: 2 0 1 7 2 0 1 6 Cash and...
-
Fred Farmer needs to prepare a balance sheet for his bank. He spent the day getting the following information. Fred needs your help to build a balance sheet and evaluate it. The information was...
-
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...
-
Stonewall Corporation issued \(\$ 20,000\) of \(5 \%, 10\)-year convertible bonds. Each \(\$ 1,000\) bond is convertible to 10 shares of common stock (par \$50) of Stonewall Corporation. The bonds...
-
On January 1, 2020, Rocket Corporation issued \(\$ 250,000\) of \(6 \%, 20\)-year bonds at 98 . The interest is payable each December 31. Rocket uses straight-line amortization. The company's...
-
Dillon Corp. issued \(\$ 100,000\) of \(6 \%\) (cash payable each December 31), 10 -year bonds on January 1, 2020. The bonds are callable at any point after 2024 at 103. The bonds sold on January 1,...
Study smarter with the SolutionInn App