Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2: Write a Java class called ArrayTwoDim.java which calculates the sum of rows and columns of a 2D array (Matrix) and displays the 2D

Problem 2:

Write a Java class called ArrayTwoDim.java which calculates the sum of rows and columns of a 2D array (Matrix) and displays the 2D array.

The 2D array is already provided in Java class ArrayTwoDimTest.java , use this class to test the ArrayTwoDim.java.

Submit only the ArrayTwoDim.java file. We will use our own ArrayTwoDimTest to test your ArrayTwoDim class when grading your submission.

Input 2D array:

20 15 6 19 18

4 46 24 17 18

12 50 23 16 31

Sample Output:

The sum of row 1 = 78

The sum of row 2 = 109

The sum of row 3 = 132

The sum of column 1 = 36

The sum of column 2 = 111

The sum of column 3 = 53

The sum of column 4 = 52

The sum of column 5 = 67

//This is given and we must use this public class ArrayTwoDim { public void sumRows(int[][] matrix) { // implement } public void sumColumns(int[][] matrix) { // implement } public void printMatrix(int[][] matrix) { // implement } }

//This is given and we must also use this public class ArrayTwoDimTest { public static void main(String[] args) { ArrayTwoDim operate = new ArrayTwoDim(); int[][] board = { { 20, 15, 6, 19, 18 }, { 4, 46, 24, 17, 18 }, { 12, 50, 23, 16, 31 } };

operate.printMatrix(board); System.out.println(); operate.sumRows(board); System.out.println(); operate.sumColumns(board); System.out.println(); // operate.largestInRows(board); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago