-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanking_system.cpp
More file actions
255 lines (235 loc) · 6.54 KB
/
Copy pathbanking_system.cpp
File metadata and controls
255 lines (235 loc) · 6.54 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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/****************PROJECT ON BANKING SYSTEM***********************/
#include<iostream>
using namespace std;
/***************************************************/
/* CLASS DEFINED */
/***************************************************/
class BankingSystem
{
private:
long int account_number,mob_number,balance,newbalance,amount;
string name,address,email;
char choice,ch;
public:
void open_new_account(int n,BankingSystem *ob);
void account_info();
void withdraw();
void deposit();
void balance_info();
int check(long int account_number,BankingSystem *ob,int n);
int ret();
};
/**************************************************/
/* FUNCTION FOR OPENING NEW ACCOUNT */
/**************************************************/
void BankingSystem::open_new_account(int n,BankingSystem *ob)
{
newbalance=0,balance=0;
int f=0;
cout<<"HEY YOU ARE OUR "<<(n+1)<<" CUSTOMER"<<endl<<endl;
cout<<"ENTER THE DESIRED ACCOUNT NUMBER"<<endl;
do{
cin>>account_number;
if(account_number==check(account_number,ob,n))
{
cout<<"ACCOUNT NUMBER ALREADY EXISTS ENTER UNIQUE ONE"<<endl;
f=1;
}
else
f=0;
}while(f==1);
getline(cin,name);
cout<<"YOUR NAME PLEASE"<<endl;
getline(cin,name);
cout<<"YOUR ADDRESS"<<endl;
getline(cin,address);
cout<<"YOUR MOBILE NUMBER"<<endl;
cin>>mob_number;
getline(cin,address);
cout<<"ENTER YOUR VALID EMAIL ID"<<endl;
getline(cin,email);
cout<<"DO YOU WANT DEPOSIT AMOUNT Y/N"<<endl;
cin>>choice;
do{
if(toupper(choice)=='Y')
{
cout<<"ENTER THE AMOUNT"<<endl;
cin>>newbalance;
balance=balance+newbalance;
}
else if(toupper(choice)=='N')
{
cout<<"NO WORRIES, YOU CAN ALSO HAVE ZERO BALANCE ACCOUNT"<<endl;
break;
}
else
cout<<"ENTER VALID CHOICE PLEASE"<<endl;
cout<<"WANT TO ADD MORE DEPOSIT ? Y/N"<<endl;
cin>>ch;
}while(toupper(ch)=='Y');
cout<<endl;
cout<<"HELLO "<<name<<" YOUR ACCOUNT NUMBER "<<account_number<<" HAS BALANCE->"<<balance<<endl<<endl;
}
/**************************************************/
/* FUNCTION FOR CHECKING THE ACCOUNT EXISTANCE */
/**************************************************/
int BankingSystem::check(long int x,BankingSystem *ob,int n)
{
for(int i=0;i<n;i++)
{
if(ob[i].ret()==x)
return x;
}
return 0;
}
/******************************************************************/
/* FUNCTION FOR GETTING ACCOUNT NUMBER OF A PARTICULAR RECORD */
/******************************************************************/
int BankingSystem::ret()
{
return account_number;
}
/**************************************************/
/* FUNCTION FOR CHECKING THE ACCOUNT INFO */
/**************************************************/
void BankingSystem::account_info()
{
cout<<"HELLO "<<name<<" YOUR ACCOUNT NUMBER "<<account_number<<" HAS BALANCE->"<<balance<<endl;
}
/**************************************************/
/* FUNCTION FOR WITHDRAWING THE AMOUNT */
/**************************************************/
void BankingSystem::withdraw()
{
cout<<"HELLO "<<name<<" HAS BALANCE-> "<<balance<<endl<<" ENTER THE AMOUNT TO BE WITHDRAWN"<<endl;
do{
cin>>amount;
if(balance<amount)
cout<<"INSUFFICIENT BALANCE"<<endl;
else
balance-=amount;
cout<<"DO YOU WANT TO CONTINUE WITHDRAWING -Y/N"<<endl;
cin>>ch;
}while(toupper(ch)=='Y');
cout<<"NEW BALANCE IS "<<balance<<endl;
}
/**************************************************/
/* FUNCTION FOR DEPOSITING THE AMOUNT */
/**************************************************/
void BankingSystem::deposit()
{
cout<<"HELLO "<<name<<" HAS BALANCE-> "<<balance<<endl<<" ENTER THE AMOUNT TO DEPOSIT"<<endl;
do{
cin>>amount;
balance+=amount;
cout<<"DO YOU WANT TO CONTINUE DEPOSITING -Y/N"<<endl;
cin>>ch;
}while(toupper(ch)=='Y');
cout<<"NEW BALANCE IS "<<balance<<endl;
}
/**************************************************/
/* FUNCTION FOR CHECKING THE BALANCE INFO */
/**************************************************/
void BankingSystem::balance_info()
{
cout<<"HELLO "<<name<<" YOU HAS BALANCE-> "<<balance<<endl;
}
/**************************************************/
/* MAIN FUNCTION DEFINED */
/**************************************************/
int main(void)
{
int wish,i=0,n=0,f=0;;
char demand;
BankingSystem ob[100];
long int tmp=ob[0].ret();
do{
f=0;
cout<<"\t\t\t"<<"WELCOME TO SECTION C BANK "<<endl<<endl;
cout<<"PRESS 1 TO OPEN NEW ACCOUNT"<<endl;
cout<<"PRESS 2 TO CHECK YOUR ACCOUNT INFO"<<endl;
cout<<"PRESS 3 TO WITHDRAW AMOUNT"<<endl;
cout<<"PRESS 4 TO DEPOSIT AMOUNT"<<endl;
cout<<"PRESS 5 TO CHECK YOUR BALANCE INFO"<<endl;
cout<<"PRESS 6 TO EXIT"<<endl<<endl;
cout<<"ENTER YOUR WISH"<<endl;
cin>>wish;
switch(wish)
{
case 1:
ob[i].open_new_account(n,ob);
n=n+1;
i=i+1;
break;
case 2:
do{
cout<<"ENTER YOUR ACCOUNT NUMBER"<<endl;
cin>>tmp;
for(int j=0;j<=n-1;j++){
if(tmp==ob[j].ret()){
ob[j].account_info();
f=1;
break;
}
}
if(f==0)
cout<<"INVALID ACCOUNT NUMBER"<<endl;
cout<<"DO YOU WANT TO CHECK OTHER ACCOUNT DETAILS -Y/N"<<endl;
cin>>demand;
}while(toupper(demand)=='Y');
break;
case 3:
cout<<"ENTER YOUR ACCOUNT NUMBER"<<endl;
cin>>tmp;
for(int j=0;j<=n-1;j++){
if(tmp==ob[j].ret()){
ob[j].withdraw();
f=1;
break;
}
}
if(f==0)
cout<<"INVALID ACCOUNT NUMBER"<<endl;
break;
case 4:
cout<<"ENTER YOUR ACCOUNT NUMBER"<<endl;
cin>>tmp;
for(int j=0;j<=n-1;j++){
if(tmp==ob[j].ret()){
ob[j].deposit();
f=1;
break;
}
}
if(f==0)
cout<<"INVALID ACCOUNT NUMBER"<<endl;
break;
case 5:
do{
cout<<"ENTER YOUR ACCOUNT NUMBER"<<endl;
cin>>tmp;
for(int j=0;j<=n-1;j++){
if(tmp==ob[j].ret()){
ob[j].balance_info();
f=1;
break;
}
}
if(f==0)
cout<<"INVALID ACCOUNT NUMBER"<<endl;
cout<<"DO YOU WANT TO CHECK OTHER ACCOUNT DETAILS -Y/N"<<endl;
cin>>demand;
}while(toupper(demand)=='Y');
break;
case 6:
cout<<"THANK YOU"<<endl;
demand='N';
break;
default:
cout<<"INVALID CHOICE";
break;
}
cout<<"DO YOU WANT TO CONTINUE BANKING-Y/N"<<endl;
cin>>demand;
}while(toupper(demand)=='Y');
}