-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
105 lines (84 loc) · 2.43 KB
/
Copy pathmain.cpp
File metadata and controls
105 lines (84 loc) · 2.43 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
Name: Daimeun Praytor
FSUID: Dcp18z
Section: 7
*/
#include <iostream>
#include <cctype> // For toupper().
#include "Portfolio.h"
void printMenu(); // Prints option menu.
char optionSelect(); // Gets a valid option.
int main()
{
Portfolio portfolio;
char option; // For menu option input.
printMenu();
do
{
option = optionSelect(); // Gets valid menu option
// Executes functions based on option selected.
switch (option)
{
// For importing file.
case 'I':
char fileName[30];
cout << "Enter filename: ";
cin >> fileName;
portfolio.importFile(fileName);
break;
// To give a brief summary of accounts.
case 'S':
portfolio.showAccounts();
break;
// Creates a output file with the account summary.
case 'E':
char fileName2[30];
cout << "Enter filename: ";
cin >> fileName2;
portfolio.createReportFile(fileName2);
break;
// Sorts accounts by name.
case 'O':
portfolio.Sort();
break;
// Prints the menu options.
case 'M':
printMenu();
break;
// Exits program.
case 'Q':
cout << "\nGoodbye" << endl;
break;
default:
break;
}
}while(option != 'Q');
return 0;
}
void printMenu()
{
cout << "***Portfolio Managment Menu***\n" << endl;
cout << "I\tImport accounts from a file" << endl;
cout << "S\tShow accounts (brief)" << endl;
cout << "E\tExport a banking report (to file)" << endl;
cout << "O\tSorts accounts by name" << endl;
cout << "M\tShow this menu" << endl;
cout << "Q\tQuit program" << endl;
}
char optionSelect()
{
char option;
cout << "\n> ";
cin >> option;
option = toupper(option); // Converts the option to uppercase.
// Checks if the option is valid.
while (option != 'I' && option != 'S' && option != 'E'
&& option != 'M' && option != 'Q' && option != 'O')
{
cout << "Invalid option. Please re-enter." << endl;
cout << "> ";
cin >> option;
option = toupper(option);
}
return option;
}