forked from sharunrajeev/YourFirstContribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBanking.cpp
executable file
·169 lines (166 loc) · 4.01 KB
/
Banking.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
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
class account
{
char cust_name[20], *acc_type;
int acc_no;
protected:
float acc_bal;
public:
void create_acct(char *);
void depo();
void disp();
void wdrwl();
};
class cur_acct : public account
{
float min_bal;
public:
void chk_minbal();
}; // checkbk,no intrst,min balace maintenance
class sav_acct : public account
{
public:
void intrst();
}; // no checkbk,wdrwl,compound interest
int main()
{
sav_acct sah1;
cur_acct cah1;
int a, b;
label:
while (1)
{
cout << "\nenter type of account:\n1.saving\n2.current\n3.exit\nenter option:";
cin >> b;
switch (b)
{
case 2:
{
int c;
while (1)
{
cout << "\n\nenter function to be done:(Create account before doing other functions)\n1.create account\n2.deposit\n3.display\n4.check minimum balance\n5.withdrawal\n6.Back to previous option\nenter option:";
cin >> c;
switch (c)
{
case 1:
cah1.create_acct("current account");
break;
case 2:
cah1.depo();
break;
case 3:
cah1.disp();
break;
case 4:
cah1.chk_minbal();
break;
case 5:
cah1.wdrwl();
break;
case 6:
goto label;
break;
default:
cout << "error input";
break;
}
}
}
break;
case 1:
{
int d;
while (1)
{
cout << "\n\nenter function to be done(Create account before doing other functions):\n1.create account\n2.deposit\n3.display\n4.interest\n5.withdrawal\n6.Back to previous option\nenter option:";
cin >> d;
switch (d)
{
case 1:
sah1.create_acct("savings account");
break;
case 2:
sah1.depo();
break;
case 3:
sah1.disp();
break;
case 4:
sah1.intrst();
break;
case 5:
sah1.wdrwl();
break;
case 6:
goto label;
break;
default:
cout << "\nerror input\n";
}
}
}
break;
case 3:
exit(0);
break;
default:
cout << "error input";
break;
}
}
return 0;
}
void account::create_acct(char *s)
{
cout << "\nenter customer name:";
cin >> cust_name;
acc_type = s;
cout << "enter account no.:";
cin >> acc_no;
acc_bal = 0.0;
}
void account::depo()
{
float amt;
cout << "\nenter amount to be deposited:";
cin >> amt;
acc_bal += amt;
}
void account::disp()
{
cout << "\ncustomer name: " << cust_name;
cout << "\ncustomer account type: " << acc_type;
cout << "\naccount number: " << acc_no;
cout << "\naccount balance: " << acc_bal;
}
void cur_acct::chk_minbal()
{
min_bal = 1000;
if (acc_bal < min_bal)
{
acc_bal -= acc_bal * 0.01;
cout << "\nmin balance maintenance charge reduced from account!";
}
}
void sav_acct::intrst()
{
float rate = 0.02, y;
cout << "enter no. of years:";
cin >> y;
acc_bal += acc_bal * pow(1 + (rate / y), y);
cout << "\ninterest added";
}
void account::wdrwl()
{
float amt;
cout << "\nenter amount for withdrawal:";
cin >> amt;
if (acc_bal > amt)
acc_bal -= amt;
else
cout << "no sufiicient amount in account to withdraw";
}