-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
313 lines (280 loc) · 10 KB
/
main.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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
#include<math.h>
#include<fstream>
using namespace std;
class new_user
{
public:
int i,j,branch,a,k,r;
ofstream ob1;
ifstream ob2;
long long amt,debit;
string name,dob,email,type,aadhaar,mob;
long double bal;
void create()
{
for(k=0;k<1;k++)
{
system("cls");
cout<<"Enter your full name\n";
cin.ignore();
getline(cin, name);
cout<<"Enter your date of birth in DD-MM-YYYY Format\n";
cin>>dob;
cout<<"Enter Your 10-digit Mobile Number\n+91";
cin>>mob;
a=mob.size();
while(1)
{
if(a<10||a>10)
{
cout<<"Enter correct Mobile Number\n+91";
cin>>mob;
a=mob.size();
}
else if (a==10)
break;
}
cout<<"Enter email id\n";
cin>>email;
cout<<"Enter the type of account you wish to open (saving/current):\n";
cin>>type;
cout<<"Kindly Enter your 12 digit aadhar number\n";
cin>>aadhaar;
a=aadhaar.size();
j=4;
for(i=0;i<5;i++)
{
if(a<12||a>12)
{
cout<<"Invalid Aadhar Number"<<endl;
cout<< "Remaining Attempts: "<<j<<endl;
cout<<"Enter correct aadhar number:\n";
cin>>aadhaar;
a=aadhaar.size();
}
else
break;
j--;
}
if(a<12||a>12)
{
cout<<"You Have Exceeded The Number of Attempts\n";
continue;
}
cout<<"We have following branches:\n1- Janakpuri, Delhi\n2- Shastri Nagar, Ghaziabad\n3- Sector-34, Chandigarh\nKindly Enter the serial number of preferred branch: ";
cin>>branch;
cout<<"\nWELCOME ONBOARD WITH OUR BANK\nKindly go through our bank website for information about our various services\n";
for(i=0;i<2000;i++)
{
cout<<"Please Wait........we are generating your account id";
for(j=0;j<52;j++)
cout<<"\b";
}
srand(time(0));
ob1.open("account info.txt",ios::app);
if (branch==2)
{
r=rand()%10;
cout<<"\n\nYour Acoount ID is: 202"<<aadhaar<<r<<endl;
ob1<<"202"<<aadhaar<<r;
}
else if(branch==1)
{
r=rand()%10;
cout<<"\n\nYour Account ID is: 158"<<aadhaar<<r<<endl;
ob1<<"158"<<aadhaar<<r;
}
else if(branch==3)
{
r=rand()%10;
cout<<"\n\nYour Account ID is: 322"<<aadhaar<<r<<endl;
ob1<<"322"<<aadhaar<<r;
}
else
cout<<"\n\nInvalid Branch Choosen\n";
}
cout<<"Please note your Account ID for further enquiry\n";
system("pause");
system("cls");
cout<<"Current Account Balance: NIL\n";
cout<<"Add Account Opening Amount(min. 5000)\n";
cin>>bal;
while(1)
{
if(bal<5000)
{
cout<<"Invalid Amount....Please Try Again\n";
cin>>bal;
}
else
break;
}
cout<<"Updated balance: "<<bal<<endl;
cout<<"Account Opening Process is complete\n";
cout<<"Thank you for banking with us\n";
system("pause");
}
};
class existing_user:public new_user
{
private:
long long inpid,acc_id,tinpid;
string inpname1,inpname2,inptype,inpdob,inpmob,inpemail,inpaadhaar,tinpname1,tinpname2,tinptype,tinpdob,tinpmob,tinpemail,tinpaadhaar;
int inpbranch,tinpbranch;
long double inpbal,inpbald,tinpbal;
public:
int display()
{
int flag=0;
system("cls");
cout<<"Enter your Account ID: ";
cin>>acc_id;
ob2.open("account info.txt");
while(ob2>>inpid>>inpname1>>inpname2>>inpdob>>inpmob>>inpemail>>inptype>>inpaadhaar>>inpbranch>>inpbal)
{
if(inpid==acc_id)
{
cout<<"Account Holder Name: "<<inpname1<<" "<<inpname2<<endl<<"Account Balance: "<<inpbal<<endl;
flag=1;
}
}
if(flag!=1)
cout<<"Invalid Account ID"<<endl;
ob2.close();
system("pause");
return 0;
}
int deposit()
{
int flag=0;
system("cls");
cout<<"Enter your Account ID: ";
cin>>acc_id;
ob2.open("account info.txt");
while(ob2>>inpid>>inpname1>>inpname2>>inpdob>>inpmob>>inpemail>>inptype>>inpaadhaar>>inpbranch>>inpbal)
{
if(inpid==acc_id)
{
cout<<"Account Holder Name: "<<inpname1<<" "<<inpname2<<endl;
cout<<"Current Balance: "<<inpbal<<endl;
cout<<"Enter Amount to be deposited: ";
cin>>bal;
inpbald=inpbal+bal;
cout<<"Updated Balance: "<<inpbald<<endl;
flag=1;
break;
}
}
ob2.close();
ob2.open("account info.txt");
ob1.open("temp.txt");
while(ob2>>tinpid>>tinpname1>>tinpname2>>tinpdob>>tinpmob>>tinpemail>>tinptype>>tinpaadhaar>>tinpbranch>>tinpbal)
{
if(tinpid!=acc_id)
ob1<<tinpid<<" "<<tinpname1<<" "<<tinpname2<<" "<<tinpdob<<" "<<tinpmob<<" "<<tinpemail<<" "<<tinptype<<" "<<tinpaadhaar<<" "<<tinpbranch<<" "<<tinpbal<<endl;
else
ob1<<tinpid<<" "<<tinpname1<<" "<<tinpname2<<" "<<tinpdob<<" "<<tinpmob<<" "<<tinpemail<<" "<<tinptype<<" "<<tinpaadhaar<<" "<<tinpbranch<<" "<<inpbald<<endl;
}
ob2.close();
ob1.close();
ob1.open("account info.txt");
ob2.open("temp.txt");
while(ob2>>tinpid>>tinpname1>>tinpname2>>tinpdob>>tinpmob>>tinpemail>>tinptype>>tinpaadhaar>>tinpbranch>>tinpbal)
{
ob1<<tinpid<<" "<<tinpname1<<" "<<tinpname2<<" "<<tinpdob<<" "<<tinpmob<<" "<<tinpemail<<" "<<tinptype<<" "<<tinpaadhaar<<" "<<tinpbranch<<" "<<tinpbal<<endl;
ob1.close();
ob1.open("account info.txt",ios::app);
}
ob1.close();
ob2.close();
if(flag!=1)
cout<<"Invalid Account ID\n";
system("pause");
return 0;
}
int withdraw()
{
int flag=0;
system("cls");
cout<<"Enter your Account ID: ";
cin>>acc_id;
ob2.open("account info.txt");
while(ob2>>inpid>>inpname1>>inpname2>>inpdob>>inpmob>>inpemail>>inptype>>inpaadhaar>>inpbranch>>inpbal)
{
if(inpid==acc_id)
{
cout<<"Account Holder Name: "<<inpname1<<" "<<inpname2<<endl;
cout<<"Current Balance: "<<inpbal<<endl;
cout<<"Enter Amount to be withdrawn: ";
cin>>bal;
inpbald=inpbal;
if(bal<inpbal)
inpbald=inpbal-bal;
else
cout<<"Insufficient Account Balance\n";
cout<<"Updated Balance: "<<inpbald<<endl;
flag=1;
break;
}
}
ob2.close();
ob2.open("account info.txt");
ob1.open("temp.txt");
while(ob2>>tinpid>>tinpname1>>tinpname2>>tinpdob>>tinpmob>>tinpemail>>tinptype>>tinpaadhaar>>tinpbranch>>tinpbal)
{
if(tinpid!=acc_id)
ob1<<tinpid<<" "<<tinpname1<<" "<<tinpname2<<" "<<tinpdob<<" "<<tinpmob<<" "<<tinpemail<<" "<<tinptype<<" "<<tinpaadhaar<<" "<<tinpbranch<<" "<<tinpbal<<endl;
else
ob1<<tinpid<<" "<<tinpname1<<" "<<tinpname2<<" "<<tinpdob<<" "<<tinpmob<<" "<<tinpemail<<" "<<tinptype<<" "<<tinpaadhaar<<" "<<tinpbranch<<" "<<inpbald<<endl;
}
ob2.close();
ob1.close();
ob1.open("account info.txt");
ob2.open("temp.txt");
while(ob2>>tinpid>>tinpname1>>tinpname2>>tinpdob>>tinpmob>>tinpemail>>tinptype>>tinpaadhaar>>tinpbranch>>tinpbal)
{
ob1<<tinpid<<" "<<tinpname1<<" "<<tinpname2<<" "<<tinpdob<<" "<<tinpmob<<" "<<tinpemail<<" "<<tinptype<<" "<<tinpaadhaar<<" "<<tinpbranch<<" "<<tinpbal<<endl;
ob1.close();
ob1.open("account info.txt",ios::app);
}
ob1.close();
ob2.close();
if(flag!=1)
cout<<"Invalid Account ID\n";
system("pause");
return 0;
}
};
int main()
{
int ch;
new_user p;
existing_user q;
while(1)
{
system("cls");
cout<<" WElCOME \n\n";
cout<<"1- Create Account\n2- Check Balance\n3- Deposit\n4- Withdraw\n5- Exit\nPlease Select your Choice: ";
cin>>ch;
switch(ch)
{
case 1: p.create();
p.ob1<< " "<<p.name <<" "<<p.dob<<" " <<p.mob <<" "<<p.email <<" "<<p.type <<" "<<p.aadhaar<<" "<<p.branch<<" "<<p.bal<<endl;
p.ob1.close();
break;
case 2: q.display();
break;
case 3: q.deposit();
break;
case 4: q.withdraw();
break;
case 5: exit(0);
break;
}
}
return 0;
}