Google Search

Tuesday, October 26, 2010

CALCULATION OF BANK INTEREST USING DEFAULT ARGUMENT


PROGRAM:
#include<iostream.h>
#include<conio.h>
class arg
{
            float sum,amount,p,n,r;
            public:
                        float value(float p,int n,float r=0.15);
                        void print(char ch='*', int len=13);
};
float arg::value(float p,int n, float r)
{
            int year=1;
            float sum=p;
            while(year<=n)
{
                        sum=sum*(1+r);
                        year=year+1;
            }
            return(sum);
}
void arg:: print(char ch, int len)
{
            for(int i=1;i<=len;i++)
            cout<<ch;
            cout<<"\n";
}
void main()
{
            arg a1;
            float tot, res;
            clrscr();
            a1.print();
            tot=a1.value(5000,5);
            cout<<tot<<endl;
            a1.print();
            cout<<endl;
            res=a1.value(5000,1,0.20);
            cout<<res;
            getch();
}


0 comments:

Post a Comment