-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstructor4.cpp
82 lines (68 loc) · 1.44 KB
/
Constructor4.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
using namespace std;
class BankDeposit
{
int Amount;
int Years;
float Interest;
float returnvalue;
public:
BankDeposit(){};
BankDeposit(int a , int y , int i);
BankDeposit(int a , int y , float i);
void show();
};
BankDeposit :: BankDeposit(int a, int y, int i)
{
Amount = a;
Years = y;
Interest = float(i)/100;
returnvalue =Amount;
for (int i = 0; i < y; i++)
{
returnvalue = returnvalue * (1+Interest);
}
}
BankDeposit :: BankDeposit(int a , int y , float i){
Amount = a ;
Years = y ;
Interest = i ;
returnvalue = Amount;
for(int i = 0 ; i < y ; i++){
returnvalue = returnvalue * (1+Interest);
}
}
void BankDeposit :: show(){
cout<<endl<<"Principal amount was "<<Amount
<< ". Return value after "<<Years
<< " years is "<<returnvalue<<endl;
}
int main()
{
BankDeposit bd1 , bd2 ;
int a, y;
float i;
int R;
cout<<"Enter the Value of a , y and i"<<endl;
cin>>a>>y>>i;
bd1 = BankDeposit(a ,y , i);
bd1.show();
cout<<"Enter the Value of a , y and i"<<endl;
cin>>a>>y>>R;
bd2 = BankDeposit(a ,y , R);
bd2.show();
return 0;
}
/*
OutPut :
Enter the Value of a , y and i
500
1
0.04
Principal amount was 500. Return value after 1 years is 520
Enter the Value of a , y and i
500
1
4
Principal amount was 500. Return value after 1 years is 520
*/