-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc++ bank project.cpp
More file actions
110 lines (96 loc) · 2.45 KB
/
c++ bank project.cpp
File metadata and controls
110 lines (96 loc) · 2.45 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
#include <iostream>
using namespace std;
class details_check {
public:
bool display(int arr[][3]) {
int accno, psw;
cout << "Enter account number: ";
cin >> accno;
cout << "Enter account password: ";
cin >> psw;
for (int i = 0; i < 5; i++) {
if (arr[i][0] == accno && arr[i][1] == psw) {
return true;
}
}
return false;
}
};
class withdrawal {
public:
void performWithdrawal(int arr[][3]) {
int accno, amount;
cout << "Enter account number: ";
cin >> accno;
cout << "Enter withdrawal amount: ";
cin >> amount;
for (int i = 0; i < 5; i++) {
if (arr[i][0] == accno) {
if (arr[i][2] >= amount) {
arr[i][2] -= amount;
cout << "Withdrawal successful. Updated balance: " << arr[i][2] << endl;
} else {
cout << "Insufficient balance for withdrawal." << endl;
}
return;
}
}
cout << "Account not found." << endl;
}
};
class deposit {
public:
void performDeposit(int arr[][3]) {
int accno, amount;
cout << "Enter account number: ";
cin >> accno;
cout << "Enter deposit amount: ";
cin >> amount;
for (int i = 0; i < 5; i++) {
if (arr[i][0] == accno) {
arr[i][2] += amount;
cout << "Deposit successful. Updated balance: " << arr[i][2] << endl;
return;
}
}
cout << "Account not found." << endl;
}
};
int main() {
int l;
cout << "Enter the number of details to be initialized first: ";
cin >> l;
int a[l][3];
for (int i = 0; i < l; i++) {
cout << "Enter the account number for registering: ";
cin >> a[i][0];
cout << "Enter the account password: ";
cin >> a[i][1];
cout << "Enter the account balance: ";
cin >> a[i][2];
}
for (int i = 0; i < l; i++) {
cout << "Account " << a[i][0] << " Balance: " << a[i][2] << endl;
}
details_check obj;
if (obj.display(a)) {
cout << "Options:\n1) Withdraw\n2) Deposit\nEnter option: ";
int choice;
cin >> choice;
withdrawal withdrawObj;
deposit depositObj;
switch (choice) {
case 1:
withdrawObj.performWithdrawal(a);
break;
case 2:
depositObj.performDeposit(a);
break;
default:
cout << "Invalid option." << endl;
}
} else {
cout << "Invalid account credentials." << endl;
}
return 0;
}