Solution of Programming Exercise : 5.1 [ Object Oriented Programming With C++ -  By    " E. Balagurusamy"]

### Question ::
                           Define a class to represent a bank account.Including the Following Members : :

### Data Members ::

1.Name of the depositor.
2.Account number.
3.Type of account.
4.Balance amount in account.

###Member Functions : :

1.To assign initial values.
2.To deposite an amount.
2.To withdraw an amount after checking the balance.
4.To display Name and balance.


### Solution ::


Header files should be written yourself.
 

class bnac
{
char name[10];
char an[5];
int ba,ty;
public:
 void init(void);
 //void diposit();
 void withdraw(void);
 void display(void);
};



void bnac::init(void)
{
 int a,d,mid,x;
 char c[30];
 cout<<"Enter your name::";
 cin>>name;
 cout<<"\nEnter account number::";
 cin>>an;
 //an=x;
 cout<<"\nWhat type of acc.do you want to open?\n";
 p:
 cout<<"1.Standard(Min. diposite 500/=) \n\n2.Exclusive(Min. diposite 1000/=)\n\n";
 cin>>ty;
 if(ty!=1&&ty!=2)
   {cout<<"You have pressed wrong button.Please try again.\n";
   goto p;}
 n:
 cout<<"\nEnter amount::";
 cin>>d;
 if(ty==1&&d<500)
 {cout<<"\n\nPlease increase your amount";
 goto n;}
 if(ty==2&&d<1000)
  {cout<<"\n\nPlease increase your amount at minimum 1000";
  goto n;}

  else
  ba=d;
  }

void bnac::withdraw(void)
 {
  int x,y;
  l:
  cout<<"\n\nEnter your amount to withdraw::";
  cin>>x;
  if(ty==1)
    {if(x>(ba-500))
   {cout<<"\n\nplease enter smaller amount.\n";
   goto l;}
   else
    cout<<"\n\nyou can withdraw :: "<<<"Taka";
    }

  if(ty==2)
    {if(x>=(ba-1000))
    {cout<<"\n\nEnter smaller amount.\n";
    goto l;}
     else
      cout<<"\n\nYou can withdraw :: "<<<"Taka";
    }

  }





 void bnac::display()
 {
  cout<<"\n\nAccount number::"<
  cout<<"\n\nNAME\t\tBALANCE\n\n";
  cout<<<"\t\t"<
  }

    void main()
    {
     js:
     clrscr();
     int x;
     bnac ac;
     char i;
     cout<<"Initializing account\n\n";
      ac.init();
      cout<<"Choice your term::\n";
      cout<<"1.Withdraw an amount.\n\n2.Display info.";
      in:
      cin>>x;

    if(x==1)
    ac.withdraw();
    if(x==2)
    ac.display();
    if(x!=1&&x!=2)
    {cout<<"You pressed wrong key.Please try again.";
     goto in;}
      cout<<"\n\n\n\nDo you want to restrart the program?\n\nPress y for yes or another to quit(Check caps lock is off.)";
        cin>>i;
        if(i=='y')
        goto js;
     getch();

  }







### If any  problem please feedback.

0 comments