Below is the c++ program of Dyanamic initialization of constructor. Please explain this program in detail.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class fixed_deposit
{
long int p_amt;
int year;
float rate,r_value;
public:
fixed_deposit()
{}
fixed_deposit(long int p,int y,float r=0.12);
fixed_deposit(long int p,int y,int r);
void display(void);
};
fixed_deposit::fixed_deposit(long int p,int y,float r)
{
p_amt=p;
year=y;
rate=r;
r_value=p_amt;
for(int i=1;i<=y;i++)
r_value=r_value*(1.0+r);
}
fixed_deposit::fixed_deposit(long int p,int y,int r)
{
p_amt=p;
year=y;
rate=r;
r_value=p_amt;
for(int i=1;i<=y;i++)
r_value=r_value*(1.0+float(r)/100);
}
void fixed_deposit::display()
{
cout<<endl<<“\t Principle amount = “<<p_amt;
cout<<endl<<“\t Return value = “<<r_value<<endl;
}
void main()
{
fixed_deposit fd1,fd2,fd3;
long int p;
int y,R;
float r;
clrscr();
cout<<“\n\t\t Calculating Fixed Deposit using overloading”;
cout<<“\n\t\t ~~~~~~~~~~~ ~~~~~~ ~~~~~~ ~~~~~ ~~~~~~~~~~~”;
cout<<“\n Enter the amount,period & interest rate(in%):”<<endl;
cin>>p>>y>>R;
fd1=fixed_deposit(p,y,R);
cout<<“\n Enter the amount,period & Interest rate(in decimal form):”<<endl;
cin>>p>>y>>r;
fd2=fixed_deposit(p,y,r);
cout<<“\n Enter the amount,period”<<endl;
cin>>p>>y;
fd3=fixed_deposit(p,y);
cout<<“\n\n RESULT:”;
cout<<“\n ~~~~~~~”;
cout<<“\n\n Deposit1: “;
fd1.display();
cout<<“\n\n Deposit2: “;
fd2.display();
cout<<“\n\n Deposit3: “;
fd3.display();
getch();
}
Answers
Answered by
0
Answer:
sgkfkk
Explanation:
ahShsdhxh djazhshkn cn
Similar questions
Geography,
2 months ago
Social Sciences,
2 months ago
Math,
4 months ago
Social Sciences,
4 months ago
Science,
10 months ago
English,
10 months ago