summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp104
1 files changed, 97 insertions, 7 deletions
diff --git a/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp b/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp
index 306f93a..882757b 100644
--- a/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp
+++ b/Project3_Hernandez_Schroeder/Project_3_Hernandez_Schroeder.cpp
@@ -184,7 +184,29 @@ void getMatrices()
- // It may also be a good thing if we were to also display the two completed matrices that the user input here...(BAS)
+ // It may also be a good thing if we were to also display the two completed matrices that the user input here...(BAS)
+ // Display the Matrices that were input
+ cout << "\n\n Matrix A:\n";
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ cout << "\t" << MatrixA[i][j] << "\t";
+ }
+ cout << "\n";
+ }
+ cout << "\n Matrix B:\n";
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ cout << "\t" << MatrixB[i][j] << "\t";
+ }
+ cout << "\n";
+ }
+ cout << "\n\n";
+
+ DisplayMenu();
}
@@ -198,7 +220,50 @@ void multiplyMatrices(float[3][3], float[3][3], float[3][3])
//row2 ..etc
//row3 ..etc
+
+
+
+ // after the multiplication is done display the input matrices and the multiplication result
+ //print out results
+ // recall Matrix A
+ cout << "\n\t MATRIX MULTIPLICATION\n Matrix A:\n";
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ cout << "\t" << MatrixA[i][j] << "\t";
+ }
+ cout << "\n";
+ }
+ // recall Matrix B
+ cout << "\n Matrix B:\n";
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ cout << "\t" << MatrixB[i][j] << "\t";
+ }
+ cout << "\n";
+ }
+ // Display Result Matrix C (the product)
+ cout << "\n A X B = C:\n";
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ cout << "\t" << MatrixC[i][j] << "\t";
+ }
+ cout << "\n";
+ }
+ cout << "\n\n";
+ DisplayMenu();
+
+}
+
+
+
+
void addMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3][3])
{
for (int i = 0; i < row; i++) // Again these commands 'row' and 'col' can be replaced with '3' for this specific program (BAS)
@@ -206,14 +271,39 @@ void addMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3][3])
MatrixC[i][j] = MatrixA[i][j] + MatrixB[i][j];
- cout << "The Sum: " << endl; //I was thinking is might be nice to also display the input matrices again before displaying the result (for clarity) (BAS)
+ //print out results
+ // recall Matrix A
+ cout << "\n\t MATRIX ADDITION\n Matrix A:\n";
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ cout << "\t" << MatrixA[i][j] << "\t";
+ }
+ cout << "\n";
+ }
+ //recall Matrix B
+ cout << "\n Matrix B:\n";
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ cout << "\t" << MatrixB[i][j] << "\t";
+ }
+ cout << "\n";
+ }
+ cout << "The Sum: " << endl; //I was thinking is might be nice to also display the input matrices again before displaying the result (for clarity) (BAS)
+ cout << "\n A + B = C:\n";
for (i = 0; i < row; i++)
- for (j = 0; j < col; j++)
- {
- cout << MatrixC[i][j] << "\t";
- if (j == col - 1)
+ for (j = 0; j < col; j++)
+ {
+ cout << MatrixC[i][j] << "\t";
+ if (j == col - 1)
cout << endl;
- }
+ }
+ cout << "\n\n";
+
+ DisplayMenu();
}