-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main_Pranav.cpp
196 lines (164 loc) · 4.58 KB
/
Main_Pranav.cpp
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*Name: Pranav Shivkumar
Title: Main.cpp (Main File)*/
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
#include"Account.h"
#include"BankAccount.h"
#include"StockAccount.h"
int main(void)
{
double dep, w;
double price;
string name;
int num, val;
int av, sv, bv;
char v1, v2, v3;
dep = w = price = 0.0;
num = val = v1 = v2 = v3 = 0;
//instantaiting objects from all classes
Account *a = new Account();
StockAccount* s = new StockAccount();
BankAccount b;
s->displayCurrentPortfolio();
while (1)
{
menu1:
cout << "Welcome to the Account Management System" << endl << endl;
cout << "Please select an account to access " << endl;
cout << "1. Stock Portfolio Account" << endl;
cout << "2. Bank Account " << endl;
cout << "3. Exit " << endl << endl;
cout << "Option: ";
cin >> av;
switch (av)
{
case 1:
menu2:
cout << "Stock Portfolio Account" << endl << endl;
cout << "Please select an option: " << endl;
cout << "1. Display the price for a current stock symbol" << endl;
cout << "2. Display the current portfolio" << endl;
cout << "3. Buy Shares" << endl;
cout << "4. Sell Shares" << endl;
cout << "5. View a graph for the portfolio value" << endl;
cout << "6. View Transaction History" << endl;
cout << "7. Return to the previous menu" << endl << endl;
cout << "Option: ";
cin >> sv;
switch (sv)
{
case 1:
cout << "Display the price for a current stock symbol" << endl << endl;
cout << "Enter the stock symbol: ";
cin >> name;
cout << endl;
price = s->displayStockPrice(name); //return the price and print in the format
cout << "Stock Symbol\t" << setw(10) << "Price Per Share" << endl;
cout << name << "\t" << setw(15) << price << endl << endl;
goto menu2;
break;
case 2:
cout << "Display the current portfolio" << endl;
s->wrapper(); //uses the sort wrapper function to sort the list in descending order of price before printing
s->printList();
goto menu2;
break;
case 3:
cout << "Buy Shares" << endl;
s->buyShares(name, num, price, b); //buy shares and update the balance
goto menu2;
break;
case 4:
cout << "Sell Shares" << endl;
s->sellShares(name, num, price, b); //sell shares andupdate balance
goto menu2;
break;
case 5:
cout << "View a graph for the portfolio value" << endl;
s->viewGraph(); //view the graph on MATLAB
goto menu2;
break;
case 6:
cout << "View Transaction History" << endl;
s->transactionHistory(); //view the transaction history
goto menu2;
break;
case 7:
cout << "Returning to the Previous Menu" << endl << endl;
goto menu1;
break;
default:
cout << "Invalid Option. Returning to menu " << endl;
goto menu2;
break;
}
break;
case 2:
menu3:
cout << "Bank Account" << endl << endl;
cout << "Please choose an option: " << endl;
cout << "1. View Account Balance" << endl;
cout << "2. Deposit Money" << endl;
cout << "3. Withdraw Money" << endl;
cout << "4. Print the History " << endl;
cout << "5. Return to the previous menu" << endl << endl;
cout << "Option: ";
cin >> bv;
switch (bv)
{
case 1:
cout << "View Account Balance" << endl << endl;
b.viewAccountBalance();
goto menu3;
break;
case 2:
//deposit money and update balance
cout << "Deposit Money" << endl;
cout << "Enter the amount you want to deposit into your account: ";
cin >> dep;
b.setDeposit(dep);
b.getDeposit();
b.depositMoney();
goto menu3;
break;
case 3:
//withdraw money and update balance
cout << "Withdraw Money" << endl;
cout << "Enter the amount you want to withdraw from your account: ";
cin >> w;
b.setWithdrawAmount(w);
b.getWithdrawAmount();
b.withdrawMoney();
goto menu3;
break;
case 4:
//print the history
cout << "Print the History" << endl << endl;
b.printHistory();
goto menu3;
break;
case 5:
cout << "Returning to the Previous Menu" << endl << endl;
goto menu1;
break;
default:
cout << "Invalid choice. Returning to menu" << endl;
goto menu3;
break;
}
break;
case 3:
//exit the program
cout << "Exiting the Program" << endl << endl;
exit(0);
break;
default:
cout << "Invalid Option. Returning to menu" << endl;
goto menu1;
break;
}
}
}