-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (50 loc) · 1.34 KB
/
main.cpp
File metadata and controls
61 lines (50 loc) · 1.34 KB
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
#include "functions.h"
//Open input file
//Create an array that contains the data
//prompt user for actions
//call corresponding function
//loop back to user prompt
int* array1 = new int[100];
int main(){ // Tried to factor out methods as best I could, main just handles the user input via switch and calls the corresponding func.
ReadInputFile(array1);
int size1 = 100;
string input = "";
int value;
int index;
while (toupper(input[0]) != 'Q'){
UserMenu();
cin >> input;
if (cin.fail()) {
cin.clear();
cin.ignore(100, '\n');
}
try{
switch (stoi(input)){
case 1:
if (IntegerExists(array1, size1))
cout << "\nExists in array" << endl << endl;
else{
cout << "\nDoes not exist in the array" << endl << endl;
}
break;
case 2:
ModifyFromIndex(array1, size1);
break;
case 3:
array1 = Append(array1, size1);
size1++;
break;
case 4:
Remove(array1, size1);
break;
default:
cout << "Enter a valid menu option" << endl;
break;
}
}
catch(std::invalid_argument e){
cout << "Quitting..." << endl;
}
}
return 0;
}