-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompoundInterest.cpp
More file actions
43 lines (37 loc) · 876 Bytes
/
CompoundInterest.cpp
File metadata and controls
43 lines (37 loc) · 876 Bytes
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
#include<iostream>
#include<math.h>
using namespace std;
class Interest
{
float interest,amount,principal,rate,time;
public:
void getData(float p, float r,float t,float am)
{
amount = am;
principal=p;
rate=r;
time=t;
}
float calculateInterest()
{
interest = principal*pow((1+rate/100),time);
return interest;
}
float display_amount()
{
amount = interest + principal;
cout<<"\nAmount = "<<amount;
}
};
int main()
{
Interest a;
float am,p,r,t,ci;
cout<<"Enter Principle, Rate and Time:\n";
cin>>p>>r>>t;
a.getData(p,r,t,am);
ci=a.calculateInterest();
cout<<"\nCompound Interest = "<<ci;
a.display_amount();
return 0;
}