diff options
| author | JordanHT-OIT <[email protected]> | 2021-12-08 17:08:42 -0800 |
|---|---|---|
| committer | JordanHT-OIT <[email protected]> | 2021-12-08 17:08:42 -0800 |
| commit | 0c39f5f945969e60e47de7224102087debcfd281 (patch) | |
| tree | da61a651753a0171cd2739c83970393b9442ec8f /mainCode.cpp | |
| parent | Add online IDE url (diff) | |
| download | cst116-proj3-jordanht-oit-0c39f5f945969e60e47de7224102087debcfd281.tar.xz cst116-proj3-jordanht-oit-0c39f5f945969e60e47de7224102087debcfd281.zip | |
Work was done within a different GitHub repo
Diffstat (limited to 'mainCode.cpp')
| -rw-r--r-- | mainCode.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/mainCode.cpp b/mainCode.cpp new file mode 100644 index 0000000..e2046b8 --- /dev/null +++ b/mainCode.cpp @@ -0,0 +1,62 @@ +//Code by Jordan Harris-Toovy ([email protected]) and Rayyan Ansari ([email protected]) for OIT's CST116-01P project 3, December 2021 + +#include "mainHeader.h" + +int main() +{ + float arr1[3][3]{ 0.0F }, arr2[3][3]{ 0.0F }, arr3[3][3]{ 0.0F }; + int menuVal = 0, displayNumberLength = 5; + bool validChoice = false; + + cout << "Plase enter the first matrix:" << endl; //Get both arrays from the user + + arrayInput(arr1); + + cout << "Plase enter the second matrix:" << endl; + + arrayInput(arr2); + + cout << "Enter desired operation: \n1) Add the first matrix to the second\n2) Multiply the second matrix by the first" + << "\n3) Multiply the first matrix by the second" << endl; + + while (!validChoice) //Get user menu choice and validate it + { + validChoice = getInt(menuVal); + + if ((menuVal > 3) || (menuVal < 1) || !validChoice) + { + cout << "Invalid entry, enter again:"; + + validChoice = false; + } + } + + switch (menuVal) + { + case (1): //Addition of arr1 and arr2 into arr3 + + addArrays(arr1, arr2, arr3); + + displayTriArray(arr1, arr2, arr3, '+'); + + break; + + case (2): //Multiplication of arr2 by arr1 into arr3 + + multiplyArrays(arr1, arr2, arr3); + + displayTriArray(arr1, arr2, arr3, 'X'); + + break; + + case (3): //Multiplication of arr1 by arr2 into arr3 + + multiplyArrays(arr2, arr1, arr3); + + displayTriArray(arr2, arr1, arr3, 'X'); + + break; + } + + return (0); +}
\ No newline at end of file |