-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPP_Basic_Bank.cpp
More file actions
314 lines (285 loc) · 9.01 KB
/
Copy pathCPP_Basic_Bank.cpp
File metadata and controls
314 lines (285 loc) · 9.01 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
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
314
#include<bits/stdc++.h>
using namespace std;
/********************
Account class decleared
**********************/
class account
{
private:
int balance,num,dep,w,count=1;
string name,u_name,u_pass,ac_no,n;
public:
/**Inline functions are declared**/
void intro();
void create_account();
void login_panel();
void deposit();
void withdraw();
void all_details();
int set_balance(int x){
balance=balance+x;
}
int get_balance(){
return balance;
}
};
/**Class loan declared and single inheritance with account class**/
class loan:public account{
int lo_amount,n_balance;
double interest;
string n;
public:
void loan_allow();
};
int main()
{
int num;
account obj;
do{
obj.intro();
cin>>num;
system("CLS");
switch(num)
{
case 1:
obj.login_panel();
break;
case 2:
obj.create_account();
break;
case 3:
cout<<endl<<endl;
cout<<"\t\t\t\t\t\t Thank you everyone..."<<endl;
cout<<"\t\t\t\t\t\t Happy Coding Life..."<<endl;
break;
}
}while(num!=3);
}
/********************
Outline function Intro
*********************/
void account::intro()
{
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| Welcome To Basic C++ Bank |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<"\t\t\t\t\t\t #Main Menu:"<<endl;
cout<<"\t\t\t\t\t____________________________________"<<endl<<endl;
cout<<"\t\t\t\tFirst create your account then going to login panel\n"<<endl<<endl;
cout<<"\t\t\t\t\t\t 1.Login Panel"<<endl;
cout<<"\t\t\t\t\t\t 2.Create Account"<<endl;
cout<<"\t\t\t\t\t\t 3.Exit "<<endl<<endl;
cout<<"\t\t\t\t\t Select your option (1-3)...."<<endl;
cout<<"\t\t\t\t\t ";
}
/***************************
Outline function create account
****************************/
void account::create_account()
{
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| Create Account |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<endl<<endl;
cout<<"\t\t\t\t\t Enter your account no: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>ac_no;
cout<<"\t\t\t\t\t Enter your name: "<<endl;
cout<<"\t\t\t\t\t ";
cin.ignore();
getline(cin,name);
cout<<"\t\t\t\t\t Enter your user name: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>u_name;
cout<<"\t\t\t\t\t Enter your password: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>u_pass;
cout<<"\t\t\t\t\t Enter your initial amount: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>balance;
cout<<endl<<endl;
cout<<"\t\t\t\t\t Account data recorded "<<endl<<endl;
cout<<"\t\t\t\t\t press 0 to go to Homepage"<<endl;
cout<<"\t\t\t\t\t ";
cin>>num;
if(num==0)
{
system("CLS");
}
else
{
cout<<"\t\t\t\t\t You pressed wrong number "<<endl;
}
}
/************************
Outline function login panel
*************************/
void account::login_panel()
{
string user;
string pass;
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| Login Panel |\n\n";
cout<<"\t\t\t\t\t===================================\n";
cout<<u_name<<endl;
cout<<u_pass<<endl;
cout<<endl<<endl;
cout<<"\t\t\t\t\t Enter Your User Name: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>user;
cout<<"\t\t\t\t\t Enter Your Password: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>pass;
if(user ==u_name && pass ==u_pass)
{
system("CLS");
start:
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| Your Account |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<endl;
cout<<"\t\t\t\t\t 1. All details show"<<endl<<endl;
cout<<"\t\t\t\t\t 2. Deposit"<<endl<<endl;
cout<<"\t\t\t\t\t 3. Withdraw"<<endl<<endl;
cout<<"\t\t\t\t\t 4. Loan"<<endl<<endl;
cout<<"\t\t\t\t\t 5. Exit"<<endl<<endl;
cout<<"\t\t\t\t\tPress (1 - 5) go to your desire page..."<<endl;
cout<<"\t\t\t\t\t";
cin>>num;
system("CLS");
if(num==1)
{
all_details();
goto start;
}
else if(num==2)
{
deposit();
goto start;
}
else if(num==3)
{
withdraw();
goto start;
}
else if(num==4){
loan obj;
obj.loan_allow();
goto start;
}
else if(num==5)
{
system("CLS");
}
}
else
{
system("CLS");
cout<<endl<<endl;
cout<<"\t\t\t\t\t\tSorry password is incorrect..."<<endl;
cout<<"\t\t\t\t\t\tPlease try again..."<<endl<<endl;
cout<<"\t\t\t\t\t\tPress 0 to go to the login page...."<<endl;
cin>>num;
if(num==0)
{
system("CLS");
login_panel();
}
}
}
/************************
Outline function All Details
*************************/
void account::all_details()
{
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| All Details |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<endl<<endl;
cout<<"\t\t\t\t\t Your account no: "<<ac_no<<endl<<endl;
cout<<"\t\t\t\t\t Name: "<<name<<endl<<endl;
cout<<"\t\t\t\t\t Total Balance: "<<get_balance()<<endl<<endl;
}
/*********************
Outline function Deposit
**********************/
void account::deposit()
{
start:
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| Your Account |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<"\t\t\t\t\tEnter your deposit amount: ";
cin>>dep;
set_balance(dep);
cout<<endl;
cout<<"\t\t\t\t\tTransction: "<<count<<endl<<endl;
cout<<"\t\t\t\t\tNow your total balance: "<<get_balance()<<endl<<endl;
cout<<"\n\n";
cout<<"\t\t\t\tPress (y/n) y for more deposit and n for exit...."<<endl;
cout<<"\t\t\t\t\t";
cin>>n;
if(n=="y"){
count++;
goto start;
}
else{
system("CLS");
}
}
/************************
Outline function Withdraw
*************************/
void account::withdraw()
{
start:
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| Your Account |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<"\t\t\t\t\t Enter your withdraw amount: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>w;
if(balance>=w){
balance=balance-w;
cout<<"\t\t\t\t\t Transction: "<<count<<endl<<endl;
cout<<"\t\t\t\t\t Now your total balance: "<<get_balance()<<endl;
cout<<"\t\t\t\t\t Press (y/n) y for more deposit and n for exit...."<<endl;
cout<<"\t\t\t\t\t ";
cin>>n;
if(n=="y"){
count++;
goto start;
}
}
else{
cout<<endl<<endl;
cout<<"\t\t\t\t\tNot sufficient balance in your account"<<endl;
}
}
/************************
Outline function login allow
*************************/
void loan::loan_allow(){
start:
cout<<"\t\t\t\t\t===================================\n";
cout<<"\n\t\t\t\t\t| Your Account |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<endl<<endl;
cout<<"\t\t\t\t\t Enter your loan amount: "<<endl;
cout<<"\t\t\t\t\t ";
cin>>lo_amount;
interest=(0.02*lo_amount)+lo_amount;
cout<<endl;
cout<<"\t\t\t\t\t With 2% interest you have to pay: "<<interest<<endl<<endl;
cout<<"\t\t\t\t\t You want to take this loan?(y/n)"<<endl;
cout<<"\t\t\t\t\t ";
cin>>n;
if(n=="y"){
set_balance(interest);
system("CLS");
cout<<"\n\t\t\t\t\t| Your Account |\n\n";
cout<<"\t\t\t\t\t===================================\n\n";
cout<<endl;
cout<<"\t\t\t\t\t Congratulation you got the loan "<<endl<<endl;
}
}