forked from mananj23/Induction_Y23
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment1.txt
155 lines (129 loc) · 4.17 KB
/
Assignment1.txt
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
#include <iostream>
#include <string>
using namespace std;
class BankAccountHolder {
private:
string name;
string username;
string netbankingpassword;
long accno;
public:
void setAccNo(long acc) {
accno = acc;
}
void getStatementOfAccount(string name, double balance) {
cout << "Enter the account name whose statements are required: " << name << endl;
cout << "Current Balance: " << balance << endl;
cout << "Transaction history" << endl;
}
void getAccountHolders(int listofaccounts) {
cout << "NAME\nACCOUNT NUMBER" << endl;
cout << name << "\n" << accno << endl;
}
void fastforward() {}
void changepassword(string password) {
netbankingpassword = password;
cout << "Password Changed" << endl;
}
void createAccount(string name, string username) {
cout << "Enter the name of Bank Account Holder: " << name << endl;
cout << "Enter the bank account username: " << username << endl;
cout << "Account is created." << endl;
}
};
class BankAccount {
private:
long accno;
double balance;
string opendate;
string transactiontype;
double depositAmount, withdrawAmount, transferAmount;
public:
void deposit(double deposit) {
cout << "Enter the amount you want to deposit: " << deposit << endl;
balance = balance + deposit;
cout << "Amount deposited." << endl;
}
void withdraw(double withdraw) {
cout << "Enter the amount you want to withdraw: " << withdraw << endl;
balance = balance - withdraw;
cout << "Amount withdrawn." << endl;
}
void transfer(double transfer) {
cout << "Enter the amount you want to transfer: " << transfer << endl;
balance = balance - transfer;
cout << "Amount transferred." << endl;
}
double getBalance() {
return balance;
}
};
class SavingsAccount : public BankAccount {
private:
double interestrate;
public:
void getInterestRate(double interest) {
cout << "Enter the non-zero interest rate of bank: " << interest << "%" << endl;
interestrate = interest;
}
void setInterestRate() {
if (interestrate > 6.0)
interestrate = 6.0;
}
};
class CheckingAccount : public BankAccount {
private:
double interestrate;
public:
void getInterestRate() {}
};
int main() {
string name, username, password;
double amt;
cout << "Enter name: ";
cin >> name;
cout << "Enter username: ";
cin >> username;
BankAccountHolder holder;
holder.createAccount(name, username);
cout << "Enter the new password: ";
cin >> password;
holder.changepassword(password);
int listofaccounts;
cout << "Enter list of accounts: ";
cin >> listofaccounts;
holder.getAccountHolders(listofaccounts);
double balance = 0.0; // Initialize balance
// Call getStatementOfAccount with balance
holder.getStatementOfAccount(name, balance);
char C;
do {
cout << "Type W for withdrawal \n Type T for transferring to another bank\n Type D for depositing \n Type C for closing account\n Type S for displaying balance: ";
cin >> C;
switch (C) {
case 'D':
cout << "Enter the amount to be deposited: ";
cin >> amt;
balance += amt; // Update balance
break;
case 'S':
holder.getStatementOfAccount(name, balance);
break;
case 'T':
cout << "Enter the amount to be transferred to: ";
cin >> amt;
balance -= amt; // Update balance
break;
case 'W':
cout << "Enter the amount to be withdrawn: ";
cin >> amt;
balance -= amt; // Update balance
break;
case 'C':
return 0;
default:
cout << "Invalid option!" << endl;
}
} while (C != 'C');
return 0;
}