-
Notifications
You must be signed in to change notification settings - Fork 64
/
7.cpp
184 lines (184 loc) · 4.03 KB
/
7.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
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
class account{
public:
int acc_no;
double balance;
string name;
string acc_type;
int a;
void deposit()
{
cout << "Amount to deposit: ";
double amt;
cin >> amt;
balance += amt;
}
void display()
{
cout << "Name: " << name << endl;
cout << "Acc_no: " << acc_no << endl;
cout << "Balance = " << balance << endl;
}
};
class curr_acct:public account{
public:
curr_acct(string n, int no, int x)
{
acc_no = no;
name = n;
a = x;
if(x==1)
{
acc_type = "current";
}
else if(x==2)
{
acc_type = "savings";
}
}
void cheque()
{
cout << "amount to withdraw: ";
int f;
cin >> f;
if (balance < f)
{
cout << "Insuficient balance" << endl;
}
else
{
balance -= f;
}
}
void imposepenalty()
{
if(balance < 300)
{
cout << "You have less balance than minium \n"
"balance so peanlty has been imposed\n";
balance-=50;
cout << "balance = " << balance << endl;
}
}
};
class sav_acct:public account{
public:
sav_acct(string n, int no, int x)
{
acc_no = no;
name = n;
a = x;
if(x==1)
{
acc_type = "current";
}
else if(x==2)
{
acc_type = "savings";
}
}
void withdraw()
{
double a;
cout << "Amount to withdraw: ";
cin >> a;
if(balance < a)
{
cout << "Insuficient balance" << endl;
}
else
{
balance -= a;
}
}
void cal_interest()
{
int t;
cout << "Enter number of years: ";
cin >> t;
balance = balance + (pow((1 + 10 / 100), t));
}
};
int main()
{
string name;
int acc_no;
int x;
cout << "Name: ";
cin >> name;
cout << "Acc_no: ";
cin >> acc_no;
cout << "1. Current account" << endl;
cout << "2. Savings account" << endl;
cin >> x;
if(x==1)
{
curr_acct curr(name, acc_no, x);
while (1)
{
cout << "1. Deposit" << endl;
cout << "2. cheque" << endl;
cout << "3. check balance" << endl;
cout << "4. exit" << endl;
int c;
cin >> c;
if(c==1)
{
curr.deposit();
}
else if(c==2)
{
curr.cheque();
}
else if(c==3)
{
curr.display();
}
else if(c==4)
{
exit(1);
}
curr.imposepenalty();
cout << "________________________________________" << endl;
}
}
else if(x==2)
{
sav_acct sav(name, acc_no, x);
while(1)
{
cout << "1. Deposit" << endl;
cout << "2. withdraw" << endl;
cout << "3. check balance" << endl;
cout << "4. Amount after interest" << endl;
cout << "5. exit" << endl;
int b;
cin >> b;
if(b==1)
{
sav.deposit();
}
else if(b==2)
{
sav.withdraw();
}
else if(b==3)
{
sav.display();
}
else if(b==4)
{
sav.cal_interest();
sav.display();
}
else if(b==5)
{
exit(1);
}
cout << "________________________________________" << endl;
}
}
};