summaryrefslogtreecommitdiff
path: root/Project3_Hernandez_Schroeder
diff options
context:
space:
mode:
authorBensProgramma <[email protected]>2021-11-26 12:46:40 -0800
committerGitHub <[email protected]>2021-11-26 12:46:40 -0800
commita10eea6d99f146666efc543a46d9c318a5534f3b (patch)
tree95c46bfffbaddc187cd744b3f7181aaad6904c0d /Project3_Hernandez_Schroeder
parentAdd project files. (diff)
downloadproject_3_hernandez_schroeder-a10eea6d99f146666efc543a46d9c318a5534f3b.tar.xz
project_3_hernandez_schroeder-a10eea6d99f146666efc543a46d9c318a5534f3b.zip
Delete CODE.txt
Diffstat (limited to 'Project3_Hernandez_Schroeder')
-rw-r--r--Project3_Hernandez_Schroeder/CODE.txt423
1 files changed, 0 insertions, 423 deletions
diff --git a/Project3_Hernandez_Schroeder/CODE.txt b/Project3_Hernandez_Schroeder/CODE.txt
deleted file mode 100644
index bf3bf6a..0000000
--- a/Project3_Hernandez_Schroeder/CODE.txt
+++ /dev/null
@@ -1,423 +0,0 @@
-// Project3_Hernandez_Schroeder.cpp : This file contains the 'main' function. Program execution begins and ends there.
-
-
-#include <iostream>
-using namespace std;
-
-float MatrixA[3][3]{};
-float MatrixB[3][3]{};
-float MatrixC[3][3]{};
-int menuChoice;
-
-void DisplayMenu();
-void getMatrices();
-void multiplyMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3][3]);
-void addMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3][3]);
-
-
-int main()
-{
- cout << "*****************************************************\n";
- cout << " \t 3x3 Matrix Calculator\n";
- cout << "*****************************************************\n";
- cout << "(Before we start, we need two 3x3 Matrices, A and B)\n";
-
- //Ask for two matrices to do calculations upon
- getMatrices();
-
- return 0;
-}
-
-
-
-void DisplayMenu()
-{
- cout << "\t1) Get New Matrices\n";
- cout << "\t2) Multiply Matrices\n";
- cout << "\t3) Add Matrices\n";
- cout << "\t4) Exit\n";
- menuChoice = 0;
- while (menuChoice < 1 || menuChoice>4)
- {
- cout << "\nSelect from the menu above: ";
- cin >> menuChoice;
- }
- switch (menuChoice)
- {
- case 1:
- {
- getMatrices();
- break;
- }
- case 2:
- {
- multiplyMatrices(MatrixA, MatrixB, MatrixC);
- break;
- }
- case 3:
- {
- addMatrices(MatrixA, MatrixB, MatrixC);
- break;
- }
- case 4:
- {
- cout << "\tThank You, Good Bye!!\n\n";
- break;
- }
- }
-}
-
-
-void getMatrices()
-{
- cout << "\nEnter the elements of Matrix A (by row): \n";
- for (int i = 0; i < 3; i++)
- {
- cout << "row " << i + 1 << "\n";
- for (int j = 0; j < 3; j++)
- {
- cout << "element " << j + 1 << ": ";
- cin >> MatrixA[i][j];
- }
- }
- cout << "\nEnter the Elements of Matrix B (by row):" << endl;
- for (int i = 0; i < 3; i++)
- {
- cout << "row " << i + 1 << "\n";
- for (int j = 0; j < 3; j++)
- {
- cout << "element " << j + 1 << ": ";
- cin >> MatrixB[i][j];
- }
- }
- 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();
-}
-
-void multiplyMatrices(float MatrixA[3][3], float MatrixB[3][3], float MatrixC[3][3])
-{
- // Calculate A X B = C
- // Top row of C
- MatrixC[0][0] = (MatrixA[0][0] * MatrixB[0][0]) + (MatrixA[0][1] * MatrixB[1][0]) + (MatrixA[0][2] * MatrixB[2][0]);
- MatrixC[0][1] = (MatrixA[0][0] * MatrixB[0][1]) + (MatrixA[0][1] * MatrixB[1][1]) + (MatrixA[0][2] * MatrixB[2][1]);
- MatrixC[0][2] = (MatrixA[0][0] * MatrixB[0][2]) + (MatrixA[0][1] * MatrixB[1][2]) + (MatrixA[0][2] * MatrixB[2][2]);
- // 2nd row of C
- MatrixC[1][0] = (MatrixA[1][0] * MatrixB[0][0]) + (MatrixA[1][1] * MatrixB[1][0]) + (MatrixA[1][2] * MatrixB[2][0]);
- MatrixC[1][1] = (MatrixA[1][0] * MatrixB[0][1]) + (MatrixA[1][1] * MatrixB[1][1]) + (MatrixA[1][2] * MatrixB[2][1]);
- MatrixC[1][2] = (MatrixA[1][0] * MatrixB[0][2]) + (MatrixA[1][1] * MatrixB[1][2]) + (MatrixA[1][2] * MatrixB[2][2]);
- // 3rd row of C
- MatrixC[2][0] = (MatrixA[2][0] * MatrixB[0][0]) + (MatrixA[2][1] * MatrixB[1][0]) + (MatrixA[2][2] * MatrixB[2][0]);
- MatrixC[2][1] = (MatrixA[2][0] * MatrixB[0][1]) + (MatrixA[2][1] * MatrixB[1][1]) + (MatrixA[2][2] * MatrixB[2][1]);
- MatrixC[2][2] = (MatrixA[2][0] * MatrixB[0][2]) + (MatrixA[2][1] * MatrixB[1][2]) + (MatrixA[2][2] * MatrixB[2][2]);
-
- //print out results
- 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";
- }
- 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 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 < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- MatrixC[i][j] = MatrixA[i][j] + MatrixB[i][j];
- }
- }
-
- //print out results
- 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";
- }
- 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 A + 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();
-}
-
-// ///////////////////////////////// RUN ////////////////////////////////////
-
-
-*****************************************************
- 3x3 Matrix Calculator
-*****************************************************
-(Before we start, we need two 3x3 Matrices, A and B)
-
-Enter the elements of Matrix A (by row):
-row 1
-element 1: 2
-element 2: 3
-element 3: 2
-row 2
-element 1: 3
-element 2: 4
-element 3: 3
-row 3
-element 1: 6
-element 2: 5
-element 3: 7
-
-Enter the Elements of Matrix B (by row):
-row 1
-element 1: 8
-element 2: 7
-element 3: 6
-row 2
-element 1: 4
-element 2: 5
-element 3: 6
-row 3
-element 1: 2
-element 2: 3
-element 3: 5
-
-
- Matrix A:
- 2 3 2
- 3 4 3
- 6 5 7
-
- Matrix B:
- 8 7 6
- 4 5 6
- 2 3 5
-
-
- 1) Get New Matrices
- 2) Multiply Matrices
- 3) Add Matrices
- 4) Exit
-
-Select from the menu above: 3
-
- MATRIX ADDITION
- Matrix A:
- 2 3 2
- 3 4 3
- 6 5 7
-
- Matrix B:
- 8 7 6
- 4 5 6
- 2 3 5
-
- A + B = C:
- 10 10 8
- 7 9 9
- 8 8 12
-
-
- 1) Get New Matrices
- 2) Multiply Matrices
- 3) Add Matrices
- 4) Exit
-
-Select from the menu above: 2
-
- MATRIX MULTIPLICATION
- Matrix A:
- 2 3 2
- 3 4 3
- 6 5 7
-
- Matrix B:
- 8 7 6
- 4 5 6
- 2 3 5
-
- A X B = C:
- 32 35 40
- 46 50 57
- 82 88 101
-
-
- 1) Get New Matrices
- 2) Multiply Matrices
- 3) Add Matrices
- 4) Exit
-
-Select from the menu above: 4
- Thank You, Good Bye!!
-
-
-C:\Users\Lenovo\source\repos\Project3_Hernandez_Schroeder\Debug\Project3_Hernandez_Schroeder.exe (process 14836) exited with code 0.
-To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
-Press any key to close this window . . .
-
-
-*****************************************************
- 3x3 Matrix Calculator
-*****************************************************
-(Before we start, we need two 3x3 Matrices, A and B)
-
-Enter the elements of Matrix A (by row):
-row 1
-element 1: 2.67
-element 2: 4.54
-element 3: 3.89
-row 2
-element 1: 2.432
-element 2: 6.765
-element 3: 4.876
-row 3
-element 1: 3.2
-element 2: 3.9
-element 3: 2.1
-
-Enter the Elements of Matrix B (by row):
-row 1
-element 1: 1.89
-element 2: .79
-element 3: .90
-row 2
-element 1: .321
-element 2: 4.5
-element 3: 3.76543
-row 3
-element 1: 2.0
-element 2: 2.8
-element 3: 12.15
-
-
- Matrix A:
- 2.67 4.54 3.89
- 2.432 6.765 4.876
- 3.2 3.9 2.1
-
- Matrix B:
- 1.89 0.79 0.9
- 0.321 4.5 3.76543
- 2 2.8 12.15
-
-
- 1) Get New Matrices
- 2) Multiply Matrices
- 3) Add Matrices
- 4) Exit
-
-Select from the menu above: 2
-
- MATRIX MULTIPLICATION
- Matrix A:
- 2.67 4.54 3.89
- 2.432 6.765 4.876
- 3.2 3.9 2.1
-
- Matrix B:
- 1.89 0.79 0.9
- 0.321 4.5 3.76543
- 2 2.8 12.15
-
- A X B = C:
- 14.2836 33.4313 66.7616
- 16.52 46.0166 86.9053
- 11.4999 25.958 43.0802
-
-
- 1) Get New Matrices
- 2) Multiply Matrices
- 3) Add Matrices
- 4) Exit
-
-Select from the menu above: 3
-
- MATRIX ADDITION
- Matrix A:
- 2.67 4.54 3.89
- 2.432 6.765 4.876
- 3.2 3.9 2.1
-
- Matrix B:
- 1.89 0.79 0.9
- 0.321 4.5 3.76543
- 2 2.8 12.15
-
- A + B = C:
- 4.56 5.33 4.79
- 2.753 11.265 8.64143
- 5.2 6.7 14.25
-
-
- 1) Get New Matrices
- 2) Multiply Matrices
- 3) Add Matrices
- 4) Exit
-
-Select from the menu above: 4
- Thank You, Good Bye!!
-
-
-C:\Users\Lenovo\source\repos\Project3_Hernandez_Schroeder\Debug\Project3_Hernandez_Schroeder.exe (process 26268) exited with code 0.
-To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
-Press any key to close this window . . .
-