-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut33.cpp
67 lines (63 loc) · 1.46 KB
/
tut33.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
#include <iostream>
using namespace std;
void name()
{
cout << 'Author: Varun Gupta' << endl;
}
class Calculate
{
//Compound Interest.
int principal;
int years;
double interestRate;
double returnvalue;
public:
Calculate() {}
// Calculate(){}
Calculate(int p, int y, double r)
{
principal = p;
years = y;
interestRate = r;
returnvalue = principal;
for (int i = 0; i < y; i++)
{
returnvalue = (returnvalue * (1 + interestRate));
}
}
Calculate(int p, int y, int r)
{
principal = p;
years = y;
interestRate = float(r)/100;
returnvalue = principal;
for (int i = 0; i < y; i++)
{
returnvalue = (returnvalue * (1 + interestRate));
}
}
void outdata()
{
cout << "The principal amount " << principal
<< " invested for no of " << years << " years is " << returnvalue << endl;
}
};
int main()
{
name();
Calculate c1, c2, c3;
int p, y;
double r;
int R;
cout << "Enter the principal amount , no of years and the interest rate " << endl;
cin >> p >> y >> r;
// Calculate c1=Calculate(p,y,r);
c1 = Calculate(p, y, r);
c1.outdata();
cout << "Enter the principal amount , no of years and the interest rate " << endl;
cin >> p >> y >> R;
// Calculate c2=Calculate(p,y,R);
c2 = Calculate(p, y, R);
c2.outdata();
return 0;
}