<iostream>
using namespace std;
class Fixed_deposit
{
pamount;
years;
rates;
R_value;
:
Fixed_deposit()
{
}
Fixed_deposit( p, y, r=0.12);
Fixed_deposit( p, y, r);
void display();
};
Fixed_deposit::Fixed_deposit( p, y, r)
{
pamount=p;
years=y;
rates=r;
R_value=pamount;
for( i=1;i<=y;i++)
{
R_value=R_value*(1.0+r);
}
}
Fixed_deposit::Fixed_deposit( p, y, r)
{
pamount=p;
years=y;
rates=r;
R_value=pamount;
for(int i=1;i<=y;i++)
{
R_value=R_value*(1.0+float(r)/100);
}
}
Fixed_deposit::display()
{
std::cout<<"\n";
std::cout<<"principal amount="<< pamount <<" \n";
std::cout << "return value="<<R_value<<"\n";
}
main()
{
Fixed_deposit fd1,fd2,fd3;
p;
y;
R;
r;
std::cout <<"Enter amount, period, interest rate(in percentage)" << "\n";
std::cin >>p>> y>> R;
fd1=Fixed_deposit(p,y,R);
std::cout<<"Enter amount, period, interest rate(decimal form)" <<"\n";
std::cin>>p >>y >> r;
fd2=Fixed_deposit(p,y,r);
std::cout<<"Enter amount and period" << "\n";
std::cin>>p >> y;
fd3=Fixed_deposit(p,y);
std::cout <<"\nDeposit 1";
fd1.display();
std::cout <<"\n desposit 2";
fd2.display();
std::cout <<"\n deposit 3";
fd3.display();
}
|