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
-
In order to respond to the particular needs of the growing number of nontraditional students, Raccoon State University announces a new Office for Non-Traditional Student Life (NTSL), a new group that...
-
Here is a data set: 30 52 56 59 52 43 40 49 43 69 47 68 61 33 43 48 54 34 33 49 46 34 33 36 42 41 45 41 42 38 You are examining the data with a stem-and-leaf plot. Here is the start of the plot 3#...
-
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...
-
You are given a water-soluble compound X. Describe how you would determine whether it is an electrolyte or a non electrolyte. If it is an electrolyte, how would you determine whether it is strong or...
-
Consider the flow of air through a pipe of inside diameter \(=0.15 \mathrm{~m}\) and length \(=30 \mathrm{~m}\). The inlet flow conditions are \(M_{1}=0.3, p_{1}=1 \mathrm{~atm}\), and \(T_{1}=273...
-
\(\frac{b^{6}}{b^{19}}\) Simplify the expression.
-
The comparative balance sheets of Menachem Corporation at the beginning and end of the year 2012 appear below. Net income of $34,000 was reported, and dividends of $23,000 were paid in 2012. New...
-
Question please find out. At the end of the current year, 2020, Gurupreet Sandhu owned two residential rental properties. Rental property #1 cost $135,000 (land $50,000; building $85,000) and at the...
-
The city manager of a large midwestern city was negotiating with the three unions that represented the police, firefighters, and building inspectors over the salaries for these groups of employees....
-
Could you elucidate the procedure involved in handling device interrupts within the context of computer systems, employing advanced terminology?
-
What role do regulatory frameworks, such as the Basel Accords, play in establishing minimum capital and liquidity standards for banks' deposit holdings, and how do these standards contribute to...
-
A project has projected cash flows of -$125,000, $35,000, $50,000, -$10,000 and $100,000 for years 0 to 4, respectively. Should this project be accepted based on the modified internal rate of return...
-
What is TRANSFORMATIONAL LEADERSHIP? Examine transformational leadership. How does it differ from other models of leadership? Explain some of the issues involved in implement transformational...
-
Can you elucidate the significance of deposit insurance schemes in fostering public confidence in the banking system, detailing how these mechanisms operate to protect depositors and mitigate the...
-
Resolute Limited reported the following items on their Statement of Financial Position: Prepaid Expenses $85,000 Current liabilities (interest bearing) 135,000 Long-term note payable 250,000 Bonds...
-
The solid V is the cube -1 x 1, -1 y 1, -1 < <1. The closed surface S is the boundary of V. The vector field F is defined by F(x, y, z) = yx2i+yj+zk i) State the Divergence Theorem. ii) Apply the...
-
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...
-
Write a program that displays the day of the week for a given day, month, and year, as shown in Figure 39.39. The program lets the user select a day, month, and year, and click the Get Day of Week...
-
Revise Programming Exercise 6.30 to run it 10,000 times and display the number of winning games.
-
Write a program that prompts the user to enter a text file name and displays the number of vowels and consonants in the file. Use a set to store the vowels A, E, I, O, and U.
-
Question: An aunt saw her eight-year-old nephew enter the room, remarked what a nice boy he was, and said, "I would like to take care of him now." She promptly wrote a note, promising to pay the boy...
-
Question: Rick is selling his espresso coffee maker. He sends Tamara an e-mail, offering to sell the machine for $350. Tamara promptly e-mails back, offering to buy the item for $300. She hears...
-
1. Interactive Data Corp. hired Daniel Foley as an assistant product manager at a starting salary of $18,500. Over the next six years, Interactive steadily promoted Foley until he became Los Angeles...
Study smarter with the SolutionInn App