BANK DEPOSIT USING DYNAMIC INITIALISATION OF OBJECT IN C#

SOURCE CODE :

//programed by Paras Wadher
MCA
Nagpur university

// WAP FOR COMMERCIAL BANK FOR LONG TERM DEPOSIT SCHEME USING DYNAMIC INITIALISATION OF OBJECT //

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class fixed_deposit
{
long int p_amt; //principal amount
int years; //period of investment
float rate; //interest rate
float R_value; //return value of amount
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;
years=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;
years=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(void)
{
cout<<“\n”
<<“Principal amount =”<<p_amt<<“\n”
<<“Return value =”<<R_value<<“\n”;
}
int main()
{
clrscr();
fixed_deposit fd1,fd2,fd3;
long int p;
int y;
float r;
int R;

cout<<“Enter amount,period,interest rate(in percent):”;
cin>>p>>y>>R;
fd1=fixed_deposit(p,y,R);

cout<<“\nEnter amount,period,interest rate(in decimal):”;
cin>>p>>y>>r;
fd2=fixed_deposit(p,y,r);

cout<<“\nEnter amount and period:”;
cin>>p>>y;
fd3=fixed_deposit(p,y);

cout<<“\nDeposit 1:”;
fd1.display();

cout<<“\nDeposit 2:”;
fd2.display();

cout<<“\nDeposit 3:”;
fd3.display();
getch();
return(0);
}

********* OUTPUT *********

Enter amount,period,interest rate(in percent):10000 3 18

Enter amount,period,interest rate(in decimal):10000 3 0.18

Enter amount and period:10000 3

Deposit 1:
Principal amount =10000
Return value =16430.320313

Deposit 2:
Principal amount =10000
Return value =16430.320313

Deposit 3:
Principal amount =10000
Return value =14049.280273

Leave a Reply

Your email address will not be published. Required fields are marked *