Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

Program of maintaining banking account information system using inheritance

Posted By: Easy Tutor     Category: C++ Programming     Views: 66159

Write a program that accepts customer account information

1) Customer Name
2) Account Number
3) Account Type

and provides below operations on customer account

1) Deposit
2) Withdraw
3) Display Balance
4) Display full account details

using inheritance.

Code for Program of maintaining banking account information system using inheritance in C++ Programming


#include <iostream.h>
#include <conio.h>

class account
{
  char cust_name[20];
  int  acc_no;
  char acc_type[20];
public:
   void get_accinfo()
   {
       cout<<"\n\nEnter Customer Name :- ";
       cin>>cust_name;
       cout<<"Enter Account Number :- ";
       cin>>acc_no;
       cout<<"Enter Account Type :- ";
       cin>>acc_type;
   }
   void display_accinfo()
   {
       cout<<"\n\nCustomer Name :- "<<cust_name;
       cout<<"\nAccount Number :- "<<acc_no;
       cout<<"\nAccount Type :- "<<acc_type;
   }
};

class cur_acct : public account
{
staticfloat balance;
  public:
    void disp_currbal()
    {
      cout<<"\nBalance :- "<<balance;
    }
    void deposit_currbal()
    {
      float deposit;
      cout<<"\nEnter amount to Deposit :- ";
      cin>>deposit;
      balance = balance + deposit;
    }
    void withdraw_currbal()
    {
      float penalty,withdraw;
      cout<<"\n\nBalance :- "<<balance;
      cout<<"\nEnter amount to be withdraw :-";
      cin>>withdraw;
      balance=balance-withdraw;
      if(balance < 500)
      {
      penalty=(500-balance)/10;
      balance=balance-penalty;
      cout<<"\nBalance after deducting penalty : "<<balance;
      }
      elseif(withdraw > balance)
      {
      cout<<"\n\nYou have to take permission for Bank Overdraft Facility\n";
      balance=balance+withdraw;
      }
      else
      cout<<"\nAfter Withdrawl your Balance revels : "<<balance;
     }
};

class sav_acct : public account
{
staticfloat savbal;
  public:
     void disp_savbal()
    {
      cout<<"\nBalance :- "<<savbal;
    }
    void deposit_savbal()
    {
      float deposit,interest;
      cout<<"\nEnter amount to Deposit :- ";
      cin>>deposit;
      savbal = savbal + deposit;
      interest=(savbal*2)/100;
      savbal=savbal+interest;
    }
    void withdraw_savbal()
    {
      float withdraw;
      cout<<"\nBalance :- "<<savbal;
      cout<<"\nEnter amount to be withdraw :-";
      cin>>withdraw;
      savbal=savbal-withdraw;
      if(withdraw > savbal)
      {
      cout<<"\n\nYou have to take permission for Bank Overdraft Facility\n";
      savbal=savbal+withdraw;
      }
      else
      cout<<"\nAfter Withdrawl your Balance revels : "<<savbal;
     }
};


float cur_acct :: balance;
float sav_acct  :: savbal;


void main()
{
 clrscr();
 cur_acct c1;
 sav_acct s1;

 cout<<"\nEnter S for saving customer and C for current a/c customer\n\n";
 char type;
 cin>>type;

 int choice;

   if(type=='s' || type=='S')
     {
       s1.get_accinfo();
       while(1)
       {
     clrscr();
     cout<<"\nChoose Your Choice\n";
     cout<<"1)   Deposit\n";
     cout<<"2)   Withdraw\n";
     cout<<"3)   Display Balance\n";
     cout<<"4)   Display with full Details\n";
     cout<<"5)   Exit\n";
     cout<<"6)   Choose Your choice:-";
     cin>>choice;
     switch(choice)
     {
       case 1 : s1.deposit_savbal();
            getch();
            break;
       case 2 : s1.withdraw_savbal();
            getch();
            break;
       case 3 : s1.disp_savbal();
            getch();
            break;
       case 4 : s1.display_accinfo();
            s1.disp_savbal();
            getch();
            break;
       case 5 : goto end;
       default: cout<<"\n\nEntered choice is invalid,\"TRY AGAIN\"";
     }
       }
     }
    else
     {
       {
       c1.get_accinfo();
       while(1)
       {
     cout<<"\nChoose Your Choice\n";
     cout<<"1)   Deposit\n";
     cout<<"2)   Withdraw\n";
     cout<<"3)   Display Balance\n";
     cout<<"4)   Display with full Details\n";
     cout<<"5)   Exit\n";
     cout<<"6)   Choose Your choice:-";
     cin>>choice;
     switch(choice)
     {
       case 1 : c1.deposit_currbal();
            getch();
            break;
       case 2 : c1.withdraw_currbal();
            getch();
            break;
       case 3 : c1.disp_currbal();
            getch();
            break;
       case 4 : c1.display_accinfo();
            c1.disp_currbal();
            getch();
            break;
       case 5 : goto end;
       default: cout<<"\n\nEntered choice is invalid,\"TRY AGAIN\"";
     }
       }
     }
end:
}
}[/Code]
  
Share: 



Easy Tutor
Easy Tutor author of Program of maintaining banking account information system using inheritance is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Olive Valencia from Philippines Comment on: Sep 22
can you convert this to C?

Hafiz Yusof from Malaysia Comment on: Jul 09
this code wont work can you fix it....and are the syntax is correct for the coding

Jacob Fitzhugh from United States Comment on: Apr 16
This code doesn't work...

View All Comments