Question: For this assignment you will perform basic matrix operations (addition, subtraction, and scalar multiplication). Something Helpful You can give initial values for arrays. Ex: int[]

For this assignment you will perform basic matrix operations (addition, subtraction, and scalar multiplication).

Something Helpful

You can give initial values for arrays. Ex: int[] arr = {3, -1, 9, 10};

You can also do this for 2D arrays. Ex: int[][] arr = {{1, 2, 3}, {3, -1 , 9}};

This would give you the following Matrix:

[1 2 3] [3 -1 9]

You will create one class that has 3 methods: one for adding matrices, one for multiplying a matrix by a scalar (a number), one for subtracting matrices (this is the same as multiplying the second matrix by -1 and then adding, so utilize the two previous methods), and one for printing a matrix.

Each method should print the result.

Sample Outputs

[2 3] [4 10] + [1 -1] [3 -4] = [3 2] [7 6] 
[2 3] [4 10] * -3 = [-6 -9] [-12 -30] 
[2 3] [4 10] - [1 -1] [3 -4] = [1 4] [1 14]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!