1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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);
}
|