source file name: defaultconst.cpp
#include<iostream.h>
#include<conio.h>
class FDAmount
{
long pamt;
int yrs;
float rt;
float amount;
public:
FDAmount(){}
FDAmount(long p, int y, float r=0.12);
FDAmount(long p, int y, int r);
void display()
{
cout<<"\n" << "Principal Amount= " << pamt;
cout<<"\n "<<" Return value= "<<amount;
}
};
FDAmount::FDAmount(long p, int y, float r)
{
pamt=p;
yrs=y;
rt=r;
amount=pamt;
for(int n=1;n<=y;n++)
amount=amount*(1.0f+r);
}
FDAmount::FDAmount(long p, int y, int r)
{
pamt=p;
yrs=y;
rt=r;
amount=pamt;
for(int n=1;n<=y;n++)
amount=amount*(1.0+float(r)/100);
}
void main()
{
FDAmount FD1,FD2,FD3;
clrscr();
long p;
int y;
float r;
int R;
cout<<" enter amount, period , rate(in percent) \n";
cin>>p>>y>>R;
FD1=FDAmount(p,y,R);
cout<<" enter amount, period , rate(in decimal) \n";
cin>>p>>y>>r;
FD2=FDAmount(p,y,r);
cout<<" enter amount, period \n";
cin>>p>>y;
FD3=FDAmount(p,y);
cout<<"\n Deposit 1: ";
FD1.display();
cout<<"\n Deposit 2: ";
FD2.display();
cout<<"\n Deposit 3: ";
FD3.display();
getch();
}
output 1:
output 2:
0 Comments
Post a Comment