-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16_dyn_obj.cpp
64 lines (58 loc) · 1.39 KB
/
16_dyn_obj.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
#include<iostream>
using namespace std;
class bank {
int princple;
int years;
float rate;
float returnval;
public:
bank(){}; // iske bina compiler confuse hoga which function to call
bank(int p , int y, float r ){
princple=p;
years=y;
rate=r;
returnval=princple;
for (int i=0;i<years;i++){
returnval=returnval*(1+rate);
}
}
bank(int p , int y, int R ){
princple=p;
years=y;
rate=float(R)/100;
returnval=princple;
for (int i=0;i<years;i++){
returnval=returnval*(1+rate);
}
}
void show(){
cout << "Principle : "<<princple<<endl;
cout << "Years : "<<years<<endl;
cout << "Rate : "<<rate*100<<"%"<<endl;
cout << "Return Value of your investment : "<<returnval<<endl;
}
};
int main ()
{
bank b1,b2;
int p,y;
int R;
float r;
cout<<"Enter principle amount : ";
cin>>p;
cout<<"Enter number of years : ";
cin>>y;
cout<<"Enter rate in fraction : ";
cin>>r;
b1 = bank(p,y,r);
b1.show();
cout<<"Enter principle amount : ";
cin>>p;
cout<<"Enter number of years : ";
cin>>y;
cout<<"Enter rate in % : ";
cin>>R;
b2=bank(p,y,R);
b2.show();
return 0;
}