-
Notifications
You must be signed in to change notification settings - Fork 2
/
constructor.cpp
54 lines (52 loc) · 1.1 KB
/
constructor.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
#include<iostream>
using namespace std;
class banker{
int principle;
float interest;
int time;
int total;
public:
banker(){};
banker(int p,int r,int t){
principle=p;
interest=float(r/100);
time=t;
total=p;
for( int i=0;i<t;i++)
{
total=total*(1+interest);
}
}
banker(int p,float r,int t);
void show(void)
{
cout<<"total return after "<<time<<" years on a sum of "<<principle<<" is "<<total<<endl;
}
};
banker::banker(int p,float r,int t)
{
principle=p;
interest=r;
time=t;
total=p;
for( int i=0;i<t;i++)
{
total=total*(1+interest);
}
}
int main()
{
banker b1,b2,b3;
int p ,t, R;
float r;
cout<<"enter the values of p,r,t respectively (r should be as ratio not as percentage)"<<endl;
cin>>p>>r>>t;
b1=banker(p, r, t);
b1.show();
cout<<"enter the values of p,R,t respectively (R should be as percentage not as ratio";
cin>>p>>R>>t;
b2=banker( p, R, t);
b2.show();
b3.show();
return 0;
}