Code Competitions

Coding competition
Showing posts with label implementation of explicit constructor. Show all posts
Showing posts with label implementation of explicit constructor. Show all posts

Thursday, 13 June 2013

program to display bank account record using explicit parametrized constructor

#include<iostream.h>
#include<conio.h>
class bank
{
    private:
        float bal,r_interest,t,sum;
    public:
    bank()
    {
    }
        bank(float b1,float i1,float t1)
        {
            bank::bal=b1;
            r_interest=i1;
            t=t1;
            //display();
        }
        void display()
        {

            cout<<"\nthe customer record is "<<bal<<" "<<r_interest<<" "<<t;
        }
        int interest()
        {
          sum=(bal*r_interest*t)/100;
          return(sum);
        }

};
void main()
{
    int i,n,m;
    clrscr();
    float bal,r_interest,t;
    class bank b[5],p;
    cout<<"enter the number of customers ";
    cin>>n;
    for(i=0;i<n;i++)
    {
           cout<<"enter the inital balance,rate of interest,time in years ";
        cin>>bal>>r_interest>>t;
           b[i]=bank(bal,r_interest,t);
    }
    for(i=0;i<n;i++)
    {

        b[i].display();
        m=b[i].interest();
        cout<<'\t'<<m;
    }
    getch();
}