[Solved] CSE1321 Lab13- Multi-Dimensional Arrays

$25

File Name: CSE1321_Lab13-_Multi-Dimensional_Arrays.zip
File Size: 367.38 KB

SKU: [Solved] CSE1321 Lab13- Multi-Dimensional Arrays Category: Tag:
5/5 - (1 vote)

Exercise #1: Develop a Java program (name it SumArrayColumns) that prints out the sum of each column of a two-dimensional array. The program defines method sumColumn() takes a two-dimensional array of integers and returns a single-dimensional array that stores the sum of columns of the passed array. The program main method prompts the user to enter a 3-by-4 array, prints out the array, and then calls method sumColumns(). Final, it prints out the array retuned by method sumColumns(). Document your code, and organize and space the outputs properly as shown below.

Sample run 1:

The entered matrix:

9 1 2 4

2 2 8 0

3 3 3 3

Sum of column 0 is 14

Sum of column 1 is 6

Sum of column 2 is 13

Sum of column 3 is 7

Sample run 2:

The entered matrix:

10 10 10 10

1 1 1 1

50 50 50 50

Sum of column 0 is 61

Sum of column 1 is 61

Sum of column 2 is 61

Sum of column 3 is 61

Sample run 3:

The entered matrix:

10 10 10 10

-10 -10 -10 -10

50 51 52 53

Sum of column 0 is 50

Sum of column 1 is 51

Sum of column 2 is 52

Sum of column 3 is 53

Exercise #2: Develop a program (name it LocateLargestElement) that prints out the location of the first largest value in a two-dimensional array. The largest values may appear more than once in the array. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints out the matrix, and then calls method locateLargest(). Finally, it prints out the array retuned by method locateLargest(). Document your code, and organize and space the outputs properly as shown below.

Sample run 1:

The entered matrix:

9 1 2 4

2 11 18 20

3 20 3 12

First largest value is located at row 1 and column 3

Sample run 2:

The entered matrix:

19 11 22 44

29 51 81 20

23 90 45 90

First largest value is located at row 2 and column 1

Sample run 3:

The entered matrix:

89 11 22 44

29 51 80 20

33 10 45 10

First largest value is located at row 0 and column 0

Exercise #3: Develop a program (name it AddMatrices) that adds two matrices. The matrices must of the same size. The program defines method Addition() that takes two two-dimensional arrays of integers and returns their addition as a two-dimensional array. The program main method defines two 3-by-3 arrays of type integer. The method prompts the user to initialize the arrays. Then it calls method Addition(). Finally, it prints out the array retuned by method Addition(). Document your code, and organize and space the outputs properly as shown below.

Sample run 1:

Matrix A:

2 1 2

7 1 8

3 20 3

Matrix B:

1 1 1

1 1 1

1 1 1

A + B:

3 2 3

8 2 9

4 21 4

Sample run 2:

Matrix A:

2 2 2

2 2 2

2 2 2

Matrix B:

2 2 2

2 2 2

2 2 2

A + B:

4 4 4

4 4 4

4 4 4

Instructions:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE1321 Lab13- Multi-Dimensional Arrays
$25