-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
120 lines (111 loc) · 3.37 KB
/
main.cpp
File metadata and controls
120 lines (111 loc) · 3.37 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <iostream>
#include <fstream>
#include "bank.h"
#include "person.h"
#include "Account.h"
#include "CD.h"
#include "Checking.h"
#include "MoneyMarket.h"
#include "Savings.h"
using namespace std;
void menu();
int main() {
return 0;
}
void menu() {
int choice;
do {
cout << "\nBank Menu: \n";
cout << "1. Create CD\n";
cout << "2. Create MoneyMarket\n";
cout << "3. Create Checking Account\n";
cout << "4. Create Savings Account\n";
cout << "5. Deposit\n";
cout << "6. Withdraw\n";
cout << "7. Display Balances\n";
cout << "8. Exit\n";
cout << "Enter choice: ";
cin >> choice;
switch (choice) {
case 1: {
double balance, interestRate;
int term;
cout << "Enter initial balance: ";
cin >> balance;
cout << "Enter interest rate: ";
cin >> interestRate;
cout << "Enter term (in months): ";
cin >> term;
cd = new CD(balance, interestRate, term);
break;
}
case 2: {
double balance, interestRate;
cout << "Enter initial balance: ";
cin >> balance;
cout << "Enter interest rate: ";
cin >> interestRate;
moneyMarket = new MoneyMarket(balance, interestRate);
break;
}
case 3: {
double balance;
cout << "Enter initial balance: ";
cin >> balance;
checking = new Checking(balance);
break;
}
case 4: {
double balance, interestRate;
cout << "Enter initial balance: ";
cin >> balance;
cout << "Enter interest rate: ";
cin >> interestRate;
savings = new Savings(balance, interestRate);
break;
}
case 5: {
int accType;
double amount;
cout << "Enter account type (1-CD, 2-MM, 3-Checking, 4-Savings): ";
cin >> accType;
cout << "Enter deposit amount: ";
cin >> amount;
switch (accType) {
case 1: cd->deposit(amount); break;
case 2: moneyMarket->deposit(amount); break;
case 3: checking->deposit(amount); break;
case 4: savings->deposit(amount); break;
}
break;
}
case 6: {
int accType;
double amount;
cout << "Enter account type (1-CD, 2-MM, 3-Checking, 4-Savings): ";
cin >> accType;
cout << "Enter withdrawal amount: ";
cin >> amount;
switch (accType) {
case 1: cd->withdraw(amount); break;
case 2: moneyMarket->withdraw(amount); break;
case 3: checking->withdraw(amount); break;
case 4: savings->withdraw(amount); break;
}
break;
}
case 7: {
if (cd) cd->displayBalance();
if (moneyMarket) moneyMarket->displayBalance();
if (checking) checking->displayBalance();
if (savings) savings->displayBalance();
break;
}
case 8:
cout << "Exiting..." << endl;
break;
default:
cout << "Invalid choice, please try again." << endl;
}
} while (choice != 8);
}