Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Matrix { private int[][] matrix; /** * default constructor -- * Creates an matrix that has 2 rows and 2 columns */ public

public class Matrix {

private int[][] matrix;

/** * default constructor -- * Creates an matrix that has 2 rows and 2 columns */ public Matrix(int [][] m) { boolean valid = true; for(int r = 1; r < m.length && valid; r++) { if(m[r].length != m[0].length) valid = false; } if(valid) matrix = m; else matrix = null;

} public String toString() { String str = ""; for (int i = 0 ; i

} public Matrix sub(Matrix om) { { Matrix newMatrix = null; if(om.matrix[0].length == this.matrix[0].length) { newMatrix.matrix = new int[matrix.length][matrix.length]; for (int i = 0; i < om.matrix[0].length; i++) for (int j = 0; j < om.matrix[0].length; j++) newMatrix.matrix[i][j] = om.matrix[i][j] - this.matrix[i][j]; } return newMatrix;

} } public Matrix multi(Matrix om) { return null; } public Matrix scalar(Matrix om) { return null; } public boolean equal(Matrix om) { return false; } public Matrix transpose(Matrix om) { return null; }

//sub, multi, scalar, equal, transpose methods need editing but not sure how to fix

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

Step: 3

blur-text-image

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

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions