Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer CLEARLY and LEGIBLE. Also include code for program. Project 1: Mat

ID: 3735352 • Letter: P

Question


Please answer CLEARLY and LEGIBLE. Also include code for program. Project 1: Matrix manipulation implementing overloaded operators using arrays 5. Write a C++ program to declare a class called Matrix. The private data of the class are Row, Column and matrix. The Matrix class should at least have the following member functions: . Constructor to initialize the content of the matrix to zero . Read Matrix Overloaded operator plus to add two matrices Overloaded operator minus to subtract two matrices Overloaded operator multiplication to multiply two matrices Overloaded operator division to divide two matrices Find transpose of each matrix Overloaded operator . .Display a matrix Destructor In the main function, do as follows: Declare object Matrix_A; Declare object Matrix_B Declare object Matrix_Add; Declare object Matrix_Dif Declare object Matrix_Mul; Declare object Matrix Div; Call Matrix_A.Read_MatrixO Call Matrix_B.Read_MatrixO Call overloaded operator+0 to add two matrices and store the result in Matix_Add

Explanation / Answer

//complete code for the above mentioned problem

#include <iostream>

using namespace std;

#define s_o_m 10

class Matrix
{
int Row;
int Column;
int matrix[s_o_m][s_o_m];
public:
Matrix()
{
for(int i=0;i<s_o_m;i++)
{
for(int j=0;j<s_o_m;j++)
{
matrix[i][j]=0;
}
}
}
void Read_Matrix()
{
cout<<"Enter number of rows of the Matrix ";
cin>>Row;
cout<<"Enter number of columns of the matrix ";
cin>>Column;
cout<<"Enter the elements of the matrix(space separated) ";

for(int i=0;i<Row;i++)
{
for(int j=0;j<Column;j++)
{
cin>>matrix[i][j];
}
cout<<" ";
}
}

Matrix operator+(Matrix &A)
{
Matrix result;
if(Row!=A.Row || Column!= A.Column)
{
cout<<"Matrix addition not possible ";
result.Column=0;
result.Row=0;
}
else
{
result.Row=Row;
result.Column=Column;
}
for(int i=0;i<Row;i++)
{
for(int j=0;j<Column;j++)
{
result.matrix[i][j]=matrix[i][j]+A.matrix[i][j];
}
}
return result;
}

Matrix operator-(Matrix &A)
{
Matrix result;
if(Row!=A.Row || Column!= A.Column)
{
cout<<"Matrix subtraction not possible ";
result.Column=0;
result.Row=0;
}
else
{
result.Row=Row;
result.Column=Column;
}
for(int i=0;i<Row;i++)
{
for(int j=0;j<Column;j++)
{
result.matrix[i][j]=matrix[i][j]-A.matrix[i][j];
}
}
return result;
}

Matrix operator*(Matrix &A)
{
Matrix result;
if(Column!=A.Row||Row!=A.Column)
{
cout<<"Matrix multiplication not possible ";
result.Column=0;
result.Row=0;
}
else
{
result.Row=Row;
result.Column=A.Column;
}
for(int i=0;i<Row;i++)
{
for(int j=0;j<A.Column;j++)
{
for(int k=0;k<Column;k++)
result.matrix[i][j]+=matrix[i][k]*A.matrix[k][j];
}
}
return result;
}

Matrix operator/(Matrix &A)
{
Matrix result;
if(Row!=A.Row || Column!= A.Column)
{
cout<<"Matrix division not possible ";
result.Column=0;
result.Row=0;
}
else
{
result.Row=Row;
result.Column=Column;
}
for(int i=0;i<Row;i++)
{
for(int j=0;j<Column;j++)
{
result.matrix[i][j]=matrix[i][j]/A.matrix[i][j];
}
}
return result;
}

Matrix transpose()
{
Matrix result;
result.Column=Column;
result.Row=Row;
for(int i=0;i<Row;i++)
{
for(int j=0;j<Column;j++)
{
result.matrix[i][j]=matrix[j][i];
}
}
return result;
}

void Display_Matrix()
{
for(int i=0;i<Row;i++)
{
for(int j=0;j<Column;j++)
{
cout<<matrix[i][j];
}
cout<<" ";
}
}

~Matrix()
{

}
};


int main()
{
Matrix Matrix_A,Matrix_B,Matrix_Add,Matrix_Div,Matrix_Dif,Matrix_Mul,Transpose_A,Transpose_B;
Matrix_A.Read_Matrix();
Matrix_B.Read_Matrix();
Matrix_Add=Matrix_A+Matrix_B;
Matrix_Dif=Matrix_A-Matrix_B;
Matrix_Mul=Matrix_A-Matrix_B;
Matrix_Div=Matrix_A-Matrix_B;
Matrix_A.Display_Matrix();
Matrix_B.Display_Matrix();
Transpose_A=Matrix_A.transpose();
Transpose_B=Matrix_B.transpose();
Matrix_Add.Display_Matrix();
Matrix_Dif.Display_Matrix();
Matrix_Div.Display_Matrix();
Matrix_Mul.Display_Matrix();
Transpose_A.Display_Matrix();
Transpose_B.Display_Matrix();
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote