-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11.cpp
More file actions
135 lines (116 loc) · 2.85 KB
/
11.cpp
File metadata and controls
135 lines (116 loc) · 2.85 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
#include <iostream>
using namespace std;
class bankaccount {
protected:
int acc_number;
float balance;
public:
void setaccount(int accno, float bal) {
acc_number = accno;
balance = bal;
}
void deposit(float amount) {
balance = balance + amount;
cout<<"amount deposited successfully: "<<amount<<endl;
}
void withdraw(float amount) {
if (amount >balance)
cout<<"Insufficient balance.\n";
else
balance = balance - amount;
cout<<"amount withdrawn successfully: "<<amount<<endl;
}
void display() {
cout<<"Account Number: "<<acc_number<<endl;
cout<<"Balance: "<<balance<<endl;
}
};
class sav_account : public bankaccount {
private:
float rate_of_interest;
public:
void setsavings(int accNo, float bal, float roi) {
setaccount(accNo, bal);
rate_of_interest = roi;
}
void calculateinterest() {
float interest = balance * rate_of_interest / 100;
cout<<"Interest: "<<interest<<endl;
}
void show() {
display();
calculateinterest();
}
};
class curr_account : public bankaccount {
private:
float minimum_balance = 500;
float service_charge = 50;
public:
void setcurrent(int accno, float bal) {
setaccount(accno, bal);
}
void serv_charge() {
if (balance < minimum_balance) {
balance = balance - service_charge;
cout<<"Service charge of "<<service_charge<<" deducted.\n";
} else {
cout<<"No service charge.\n";
}
}
void show() {
serv_charge();
display();
}
};
int main() {
sav_account s1;
int n,m;
float amount,amount2;
s1.setsavings(2255, 1000, 5);
cout<<"\nSavings Account Details:\n"<<endl;
s1.show();
cout<<"click 1 for deposit"<<endl;
cout<<"click 2 for withdraw"<<endl;
cin>>n;
if(n==1){
cout<<"deposit amount : ";
cin>>amount;
s1.deposit(amount);}
else if(n==2){
cout<<"withdraw amount : ";
cin>>amount;
if(amount<=1000){
s1.withdraw(amount); }
else{
cout<<"insufficient balance"<<endl; }
}
else{
cout<<"error"<<endl;
}
s1.show();
curr_account c1;
c1.setcurrent(2266, 400);
cout<<"\nCurrent Account Details:\n"<<endl;
c1.show();
cout<<"click 1 for deposit"<<endl;
cout<<"click 2 for withdraw"<<endl;
cin>>m;
if(m==1){
cout<<"deposit amount : ";
cin>>amount2;
c1.deposit(amount2);
}
else if(m==2){
cout<<"withdraw amount : ";
cin>>amount2;
if(amount2<=400){
c1.withdraw(amount2); }
else{
cout<<"insufficient balance"<<endl; }
}
else{
cout<<"error"<<endl;
}
c1.show();
}