-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode
208 lines (196 loc) · 5.25 KB
/
Code
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
#include<iostream>
using namespace std;
class ACC {
string name;
double ACCNO;
public:
void setName(string n){
name = n;
}
void setACCNO(double A){
ACCNO=A;
}
string getname(){
return name;
}
double getACCNO(){
return ACCNO;
}
};
class savingACC : public ACC {
double Deposit;
double Balance = 500;
public:
void setDeposit(double D) {
Deposit = D;
}
void setBalance(double B){
Balance = B;
}
double getDeposit() {
return Deposit;
}
double getBalance() {
return Balance;
}
void interest(int money) {
float sertax = 2;
Balance = Balance - sertax;
}
void Withdrawl() {
int money;
cout<<"Enter the amount of money: ";
cin>>money;
if (Balance - money > 50) {
if (Balance < 500) {
cout<<"We are imposing a penalty for low minimum balance."<<endl<<endl;
int p1ty = 50;
Balance = Balance - (money + p1ty);
interest(money);
cout<<"Transaction is successful."<<endl;
} else {
Balance = Balance - money;
interest(money);
cout<<"Transaction is successful."<<endl;
}
} else {
cout<<"Transaction cannot be done."<<endl;
}
}
void Deposit1() {
int money;
cout<<"Enter the amount of money: ";
cin>>money;
Balance = Balance + money;
}
void Display(){
cout<<"\n\nBalance: "<<Balance<<endl;
cout<<"Minimum balance: 500\n\n"<<endl;
}
};
class currACC : public ACC {
double Deposit;
double Balance = 500;
public:
void setDeposit(double D){
Deposit = D;
}
void setBalance(double B){
Balance = B;
}
double getDeposit(){
return Deposit;
}
double getBalance(){
return Balance;
}
void cheque(){
int money;
string Bname;
cout<<"Enter the name of the cheque receiver: ";
cin>>Bname;
cout<<"Enter the amount of money: ";
cin>>money;
if(Balance - money > 50){
if(Balance == 0)
cout<<"Transaction cannot be done."<<endl;
else{
Balance = Balance - money;
cout<<"The transaction is successful."<<endl;
cout<<endl;
Display1(Bname, money);
}
}
}
void Deposit1(){
int money;
cout<<"Enter the amount of money: ";
cin>>money;
Balance = Balance + money;
}
void Display(){
cout<<"\n\nBalance: "<<Balance<<endl;
cout<<"Minimum balance: 500\n\n"<<endl;
}
void Display1(string Bname, int money){
cout<<"Cheque receiver: "<<Bname<<endl;
cout<<"Money: "<<money<<endl;
cout<<"Balance: "<<Balance<<endl;
}
};
int main(){
int choice;
cout<<"Enter the type of account:"<<endl;
cout<<"1. Current"<<endl;
cout<<"2. Saving"<<endl;
cout<<"Choice: ";
cin>>choice;
cout<<"\n\n\n";
switch (choice){
case 1:{
currACC c1;
string h;
cout<<"Enter the name of the account holder: ";
cin>>h;
c1.setName(h);
double k;
cout<<"Account number: ";
cin>>k;
c1.setACCNO(k);
cout<<"\n\nAccount name: "<<c1.getname()<<endl;
cout<<"Account Number: "<<c1.getACCNO()<<endl;
cout<<"Balance: "<<c1.getBalance();
do{
cout<<"\n\n1. Deposit"<<endl;
cout<<"2. Withdrawal"<<endl;
cout<<"3. Exit"<<endl;
cout<<"Enter choice: ";
cin>>choice;
switch (choice) {
case 1:
c1.Deposit1();
c1.Display();
break;
case 2:
c1.cheque();
c1.Display();
break;
}
} while (choice != 3);
break;
}
case 2:{
savingACC s1;
string h;
cout<<"Enter the name of the account holder: ";
cin>>h;
s1.setName(h);
double k;
cout<<"Account No: ";
cin>>k;
s1.setACCNO(k);
cout<<"\n\nAccount name: "<<s1.getname()<<endl;
cout<<"Account Number: "<<s1.getACCNO()<<endl;
cout<<"Balance: "<<s1.getBalance();
do{
cout<<"\n\n1. Deposit"<<endl;
cout<<"2. Withdrawal"<<endl;
cout<<"3. Exit"<<endl;
cout<<"Enter choice: ";
cin>>choice;
switch (choice) {
case 1:
s1.Deposit1();
s1.Display();
break;
case 2:
s1.Withdrawl();
s1.Display();
break;
}
} while (choice != 3);
break;
}
}
return 0;
}