Write a program for Bank Management Application

/*Bank Management Application*/
#include<iostream>
#include<fstream>
#include<stdlib.h>

using namespace std;
void all();
class acc
{
  int uni;
  long int acc_no;
  double bal;
  char acc_name[20],type[10];

  public:

   void getacc()
   {
     cout<<"\n\n New Account Form: ";


     cout<<"\n\n Enter Account Holder Name= ";
     cin>>acc_name;

     cout<<"\n Enter Account Number= ";
     cin>>acc_no;

     cout<<"\n Enter Account Balance= ";
     cin>>bal;

     cout<<"\n Enter Acount Type(Saving/Current) = " ;
     cin>>type;

     cout<<"\n Enter UniqueID = ";
     cin>>uni;
   }


  void putacc()
  {
    cout<<endl<<"\t"<<uni<<"\t";
    cout<<"\t"<<acc_name<<"\t";
    cout<<"\t"<<acc_no<<"\t";
    cout<<"\t"<<bal<<"\t";
    cout<<"\t"<<type<<"\t";
  }

};

acc a;

void all()
{
  ifstream file("bank.data",ios::in);

  cout<<"\n\n Account Details ";
  cout<<"\n\n  Unique Id \t Name \t Number \t Balance \t Type";
  while(!file.eof())
  {
    a.putacc();
    file.read((char*)&a,sizeof(a));
  }

  file.close();
}

int main()
{
  int ch;

  while(1)
  {
    cout<<"\n\n Operations: ";
    cout<<"\n *************";
    cout<<"\n 1.Create a New Account";
    cout<<"\n 2.Update Existing Account" ;
    cout<<"\n 3.Withdraw Money";
    cout<<"\n 4.All Accounts" ;
    cout<<"\n 5.Quit";

    cout<<"\n\n Enter Your Choice(1/2/3/4/5/6): ";
    cin>>ch;

    switch(ch)
    {
      case 1: ofstream file("bank.data",ios::out);
      a.getacc();
      file.write((char*)&a,sizeof(a));
      break;

      case 2: cout<<"\n Enter Unique ID to Update: ";
      cin>>id;
      break;

      case 3:
      break;

      case 4: all();
      break;

      case 5: exit(1);
      break;

      default: cout<<"\n\n WRONG CHOICE";
    }

  }
  return 0;
}






Previous
Next Post »