
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
In the test class below, integrate another method to existing method to:
Print the minimum values of each row and of each column.
public class ArrayTest {
public static void main(String[] args) {
int[][] myArray = {{1, 4, 3, 2}, {2, 4, 8, 6}, {3, 3, 3, 3}};
int[] rowMax = ArrayOperations2D.findRowMax(myArray);
for (int i = 0; i < rowMax.length; i++) {
System.out.println("Max in row " + i + " = " + rowMax[i]);
}
int[] rowSums = ArrayOperations2D.findRowSums(myArray);
for (int i = 0; i < rowSums.length; i++) {
System.out.println("Sum in row " + i + " = " + rowSums[i]);
}
int[] columnMax = ArrayOperations2D.findColumnMax(myArray);
for (int i = 0; i < columnMax.length; i++) {
System.out.println("Max in column " + i + " = " + columnMax[i]);
}
int[] columnSums = ArrayOperations2D.findColumnSums(myArray);
for (int i = 0; i < columnSums.length; i++) {
System.out.println("Sum in column " + i + " = " + columnSums[i]);
}
int[][] transpose = ArrayOperations2D.findTranspose(myArray);
System.out.println("Transpose of the matrix:");
for (int i = 0; i < transpose.length; i++) {
for (int j = 0; j < transpose[0].length; j++) {
System.out.print(transpose[i][j] + " ");
}
System.out.println();
}
}
}
public static void main(String[] args) {
int[][] myArray = {{1, 4, 3, 2}, {2, 4, 8, 6}, {3, 3, 3, 3}};
int[] rowMax = ArrayOperations2D.findRowMax(myArray);
for (int i = 0; i < rowMax.length; i++) {
System.out.println("Max in row " + i + " = " + rowMax[i]);
}
int[] rowSums = ArrayOperations2D.findRowSums(myArray);
for (int i = 0; i < rowSums.length; i++) {
System.out.println("Sum in row " + i + " = " + rowSums[i]);
}
int[] columnMax = ArrayOperations2D.findColumnMax(myArray);
for (int i = 0; i < columnMax.length; i++) {
System.out.println("Max in column " + i + " = " + columnMax[i]);
}
int[] columnSums = ArrayOperations2D.findColumnSums(myArray);
for (int i = 0; i < columnSums.length; i++) {
System.out.println("Sum in column " + i + " = " + columnSums[i]);
}
int[][] transpose = ArrayOperations2D.findTranspose(myArray);
System.out.println("Transpose of the matrix:");
for (int i = 0; i < transpose.length; i++) {
for (int j = 0; j < transpose[0].length; j++) {
System.out.print(transpose[i][j] + " ");
}
System.out.println();
}
}
}
SAVE
AI-Generated Solution
info
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
to generate a solution
Click the button to generate
a solution
a solution
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Complete the method endsInFive that takes as arguments a 2D-array of integers and an integer value that represents a column index in the array. endsInFive returns the number of values in the column that end in 5. It is possible that the array is ragged, meaning that the number of columns in each row is different. For example, 2 is returned if the following 2D-array is passed as the first argument of endsInFive and the integer 3 as the second argument (the values 25 and 115 end in five at column index 3).arrow_forwardGiven an array of numbers, and an integer, find the last index that that integer appears in the array. If the number is not found, return -1. import java.util.ArrayList;public class LastIndexFound{public static int solution(ArrayList<Integer> nums, int numToFind){// ↓↓↓↓ your code goes here ↓↓↓↓return 0;}}arrow_forwardjava Create a static method that: is called repeatAll returns ArrayList of Booleans takes in a single parameter - an ArrayList of Booleans This method should modify its ArrayList parameter by repeating its ArrayList values. For example, if the parameter is (true, false, false) The modified ArrayList should be (true, false, false, true, false, false) public static void main(String[] args) { Scanner in = new Scanner(System.in); int size = in.nextInt(); ArrayList<Boolean> list = new ArrayList<>(); for(int i=0; i < size; i++) { list.add(in.nextBoolean()); } System.out.println(repeatAll(list)); } }arrow_forward
- Javaarrow_forwardGiven the below 2 arrays: int arr1[] = { 9,8,7,6,5,4,3,2,1,0 }; int arr2[] = { 99, 89, 79, 69, 59 }; Write a program to replace 79 in arr2 with 4 from arr1. Print the final arr2 using Arrays.toString() method. Hint: Use System.arraycopy() methodNote: For all these programs, please submit the program’s .java file and screenshot of output.arrow_forwardPlease help with this java problemarrow_forward
- Need help with menu loop pleasearrow_forwardstarter code import java.util.ArrayList; public class SortsTracing { //Note: Style is not required for this file //for reference public ArrayList<int[]> SelectionSortExampleList() { ArrayList<int[]> answer = new ArrayList<int[]>(); answer.add(new int[]{-1, 20, 18, 17, 9, 4, 2, 0, 40}); answer.add(new int[]{-1, 0, 18, 17, 9, 4, 2, 20, 40}); answer.add(new int[]{-1, 0, 2, 17, 9, 4, 18, 20, 40}); answer.add(new int[]{-1, 0, 2, 4, 9, 17, 18, 20, 40}); answer.add(new int[]{-1, 0, 2, 4, 9, 17, 18, 20, 40}); answer.add(new int[]{-1, 0, 2, 4, 9, 17, 18, 20, 40}); // etc... (the rest of the iterations) return answer; } public ArrayList<int[]> InsertionSortRandomList() { ArrayList<int[]> answer = new ArrayList<int[]>(); answer.add(new int[]{30, 62, 5, 109, 66, 17, 51, 18}); // TODO return answer; } public ArrayList<int[]>…arrow_forwardIn JAVA Write the method below: Given a two-dimensional array containing integers, create a method called "matrixOperations" The method should do the following:1. Print out all the numbers in the array row by row (add empty line at the end of the row)2. For each row, print out the length of the row (each row is an array, remember)arrow_forward
- Create a method multiply(), that receives the 2D array you created in the program below as as an input, multiplies all of its elements and displays the product. Hint: your method won’t return anything import java.util.*; public class Two_D_Ragged { public static void Using_array_class(int R_array[][]) {System.out.println(""); System.out.println("using Arrays class Through the Ragged Array"); //Array.toString method is used to show array elements in R_array[0] System.out.println(Arrays.toString(R_array[0])); //Array.toString method is used to show array elements in R_array[1] System.out.println(Arrays.toString(R_array[1])); //Array.toString method is used to show array elements in R_array[2] System.out.println(Arrays.toString(R_array[2])); } //end of Using_array_class method public static void Using_for_each(int R_array[][]) { System.out.println("for-each-loop Through the Ragged Array"); int k = 0; //prints elements in R_array[0] for (int i:R_array[0]) { System.out.print(R_array[0][k]…arrow_forwardJavaarrow_forwardWrite a static method that displays all combinations of picking two numbers from the array list: public static void combinations(ArrayList<Integer> list) Include the driver program that prompts the user to enter 10 integers and displays all combinations of picking two numbers from the array list.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education