Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone solve this In java please ? Matrix Addition The sum of two matrices A and B (of the same dimensions) is denoted by

can someone solve this In java please ? image text in transcribed
image text in transcribed
Matrix Addition The sum of two matrices A and B (of the same dimensions) is denoted by C= A +B The sum of adding 2 matrixes is defined by adding entries with the same indices a; - dis + bas over all i and j. Example: a + b [1+5 2+ 3+74+8 10 12 = [{]-; :9-13+9 2+]-[6] Your task is to write the code for the following 2 methods: ** * This method adds ANY 2 matrix's of the same dimension and returns their sum + as a matrix. If both matrixes are not of the same dimension, then an error * message is printed to the screen and no addition is carried out and a null value is returned. @param a, the first 20 matrix @param b the second 2D matrix @return new 2D matrix having the sum of both alb mateixes and if both matrixes are of different dimensions then null is returned. public static int[] addateix(int[] [] a, int nb) This method prints any 2D matrix to the screen print to the screen the given 2D matrix by row first. Each row is printed on a separate line Leave some space between each column param x the 2d mateix to be printed to the screen public static void printMatrix (int! 1 ) * @param X, the 2d matrix to be printed to the screen */ public static void printMatrix(int[] [] x) You are given the following main method to test your code. public static void main(String[] args) { into a = { {1,2}, {3,4} }; int(10 b-{{3,4},{5,6) }; printMatrix(a); System.out.println(" printMatrix(b); int(0 c = addMatrix(a,b); System.out.println(" printMatrix(c); int(0 X = {{1,2}}; int[n] d - addMatrix(x, a); }

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions