I'm doing a second year student in computer and information sciences and it is the first time for me to do a project so I need help . My problem is how to enter a branch information and update the branch information,update holder information .Ijust need a hint to start. Thank you :)
Project Description:-
• This project manages the bank activities.
• The bank has many branches.
• The bank deals with many account holders and each holder has many accounts.
• Each account holder makes two operations (Deposit - Withdraw) on his accounts.
• The system should handle the holder operations on his accounts and record the data and time when this operation occurs.
• The system has three main entities:-
Branch:-
Each branch has basic information (Name – Id – Address – ….)
Holder:-
Each holder has basic information (Name – Id – SSN - Address– E-Mail-…)
Account:-
Each account has basic information (Id – Holder - Value….).
System Required Functions:-
1- For Branch:-
a. Enter branch information.
b. Display branch information.
c. Update branch information.
d. Delete branch.
e. Display branch account holders.
2- For Account holder:-
f. Enter holder information.
g. Display holder information.
h. Update holder information.

i.Delete holder with its accounts.
j. Search for holder using (id – name - branch).
k. Deposit a value to holder specific account.
l. Withdraw a value from holder specific account.
m. Display holder accounts.
n. Transfer all holder accounts from branch to another branch.
o. Transfer a specific account from branch to another branch.
3- For Account:-
p. Enter account information for specific holder.
q. Display specific account information.
4- General Functions:-
r. Display specific branch accounts.
s. Display branches ordered by the total value of its accounts.
t. Display top (10) account holders in the bank.
u. Display top (10) account holders each branch.
v. Display operations done by specific account.
w. Display all operations done by specific account in a specific duration (From date… to date…).
x. Display all operations done in a specific day.
y. Display all operations done in a specific duration (From date… to date…).
z. Find total value of money in the bank as a whole (total sum of all account values in all
branches).

You're a second year CIS student and don't even know where to start? I weep for this generation of programmers. How about starting with one account class and working out the credit/debit actions? From there you can add more accounts, set up branches, etc... This project practically slaps you in the face with the bottom-up progression of design, implementation, and testing.

Edited 5 Years Ago by Narue: n/a

I'm not really sure what kind of hint you're looking for, but, it seems like you have a good layout of your project, as well as structure and hierarchy. Basically, all you do now is follow the same order in programming.

You say a bank has several branches and each branch has holders and each holder has a certain amount of accounts.
Starting at the top, you should create four classes corresponding to these four entities that you stated: bank, branch, holder and account.

The first step, is foundation, knowing your variables.
For instance, you stated that all your entities have basic information. If you notice that there are several variables that have the same purpose, such as name, or ID. You might as well form a STRUCT that holds these basic information variables.

A different approach would be to create a parent class, above all others which your entities will inherit, and within your parent you can declare your variables and functions that share the same purposes.

The latter approach would seem more efficient as it also shares general functions and is easily implemented.

Now that we've created the four main entities' foundations, it's time to put it all together.
As you stated, the hierarchy was: bank -> branches -> holders -> accounts

  1. In the holder class, we add an account array. Representing the many accounts a holder can have.
  2. In the branch class, we add a holder array. Representing the many holders a branch can have.
  3. In the bank class, we add a branch array. Representing the many branches a bank can have.

This should give you a reasonably understandable hierarchical structure. By now, you should see that it follows your original layout and structure.

Lastly you should define functions and variables that are specific for each entity, like withdraw and deposit in the account class.

Remember to keep your code efficient and well managed.

How's that for a hint? ...

Edited 5 Years Ago by ShadowScripter: n/a

Good God! Why do you guys waste your precious time with this bullcrap? Don't help them if they can't help themselves. Prop open a book and read about classes. Once you read a chapter on classes, you're good to go assuming you know how to use arrays, what data types are, etc.

Second year CIS with 0 knowledge in programming? Tsk tsk...

Well ! I know how to do a class and arrange functions but if you looked at my question I've asked for a help in certain functions and that what i want help in considering that I'm using vector in doing my project. thanks :)

You've been studying this subject for two years. Surely you must be able to do something.

So how about showing us how much of your program you've written successfully. Then you might get a hint as to what to do next.

in the header file

#include "stdafx.h"
#include"iostream"
#include "string.h"
#include <fstream>
#include<vector>
using namespace std;
//*************** Bank Management System ****************************//
//we use the setters and getters to update or override any info easily :)

//////////////////////////////////////////////////////////////****Branch Functions****///////////////////////////////////////////////////////////////////////////////////

class Branches
{

    string BranchName;
    long BranchID;
    long BranchTelephone;
    int HotLine;
    string BranchAddress;



public:
    Branches();
    Branches(string Bn,long Bid,string Bradd,long tel,int HL);

void setBranchName(string bn);
string getBranchName();
void setBranchId(long bi);
long getBranchId();
void setBranchAddress(string BranchADD);
string getBranchAdrress();
void setBranchTel(long Tel);
long getBranchTel();
void setHotLine(int Tel);
int getHotline();
void Display();

};


//////////////****Holder Functions****////////////
    class Holder
    {

       string HName;
       string HolderAddress;
       int HID;
       int SSN;//Social Security Number
       long TelephoneNo;
       string Nationality;
       string BranchName;
       vector<string>Hlist;
    public:
        Holder();
Holder(string HN,string HAdd,int HId,int SsN,long HTel,string HNat,string BranNme);
    void setName(string n);
    string getName(void);
    void setAddress(string add);
      string getAddress();

    void setID(int id);
    long getID();
    void setSSN(int s);
    int getSSN();
    void setTelephoneNo(long tel);
    long getTelephoneNo();
    void setBranchName(string BrNme);
    string getBranchName();
    void setNationality(string N);
    string getNationality();
    void Display();
  };
//////////////****Account Functions****/////////////////////

    class Account
    {
         string HName;
           int HolderID;
         double Balance;//value in the account
        string BranchName;
        int AccountId;
       long AccountNo;
       string AccountType;
       string Currency;
      int date;//date of any operation that will be done at any time
    public:
         Account();
 Account(string HN,int HID,double bal,string BranNme,int accID,string accType);
        void setHolderName(string HNme);
        string getHolderName();
        void setHolderID(int HID);
        int getHolderID();
        void setBalance(double Bal);
        double getBalance();
        void setAccountId(int accId);
        int getAccountId();
        void setBranchName(string bN);
        string getBranchName();
        bool Withdraw(double amt);
        bool Deposit(double amt);
        void setAccountType(string accType);
        string getAccountType();
        void setDate(int d);
        int getDate();


        void Display();
    };

//************** Bank Management System *************//

in cpp file :

#include"stdafx.h"
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include"BS.h"
#include<iomanip>
using namespace std;

//************ Bank Management System ********************//


////////////****Branch Functions****/////////////

Branches::Branches(std::string Bn, long Bid, std::string Bradd, long tel, int HL)
{
        BranchName=Bn;
        BranchID=Bid;
        BranchAddress=Bradd;
        BranchTelephone=tel;
        HotLine=HL;

}


void Branches::setBranchName(string bn)
{
     BranchName = bn;
}
string Branches::getBranchName()
{
    return BranchName;
}
void Branches::setBranchId(long bi)
{
    BranchID=bi;
}
long Branches::getBranchId()
{
    return BranchID;
}
void Branches::setBranchAddress(string BranchADD)
{
    BranchAddress=BranchADD;
}
string Branches::getBranchAdrress()
{
    return BranchAddress;
}

void Branches::setBranchTel(long Tel)
{
    BranchTelephone = Tel ;
}
long Branches::getBranchTel()
{
    return BranchTelephone;
}


void Branches::setHotLine(int Tel)
{
    HotLine=Tel;
}
int Branches::getHotline()
{
    return HotLine;
}
void Branches::Display()
{

    cout<<getBranchName()<<setw(13)<<getBranchId()<<setw(20)<<getBranchAdrress()<<setw(20)<<getBranchTel() <<setw(16)<<getHotline()<<endl;
}

////////////****Holder Functions****////////////


Holder::Holder(std::string HN, std::string HAdd, int HId, int SsN, long HTel, std::string HNat, std::string BranNme)
{
     HName=HN;
     HolderAddress=HAdd;
     HID=HId;
     SSN=SsN;
     TelephoneNo=HTel;
     Nationality=HNat;
     BranchName=BranNme;

}

void Holder::setName(std::string n)
{
    HName=n;

}
string Holder::getName()
{
    return HName;
}
void Holder::setID(int id)
{
    HID=id;

} 



long Holder::getID()
{
    return HID;
}
void Holder::setAddress(std::string add)
{
    HolderAddress=add;
}
string Holder::getAddress()
{
    return HolderAddress;
}
void Holder::setSSN(int s)
{
    SSN=s;
}
int Holder::getSSN()
{
    return SSN;
}
void Holder::setTelephoneNo(long tel)
{
    TelephoneNo=tel;
}
long Holder::getTelephoneNo()
{
    return TelephoneNo;

}
void Holder::setBranchName(std::string BrNme)
{
    BranchName=BrNme;
}

string Holder::getBranchName()
{
    return BranchName;
}
void Holder::setNationality(string N)
{
    Nationality=N;
}
string Holder::getNationality()
{
    return Nationality;
}
void Holder::Display()
{
   cout<<getName()<<setw(13)<<getID()<<setw(20)<<getAddress()<<setw(20)<<getSSN()<<setw(20)<<getTelephoneNo()<<setw(16)<<getBranchName()<<setw(16)<<getNationality()<<endl;
}

////////****Account Functions****///////////////////////


Account::Account(std::string HN,int HID, double bal, std::string BranNme, int accID, std::string accType)
{
    HName=HN;
    HolderID=HID;
    Balance=bal;

    BranchName=BranNme;
    AccountId=accID;
    AccountType=accType;
}
void Account::setHolderName(std::string HNme)
{
   HName=HNme;
}
string Account::getHolderName()
{
    return HName;
}
void Account::setHolderID(int HID)
{
   HolderID=HID;
}
int Account::getHolderID()
{
    return HolderID;
}
void Account::setAccountId(int accId)
{
    AccountId=accId;
}
int Account::getAccountId()
{
    return AccountId;
}

void Account::setAccountType(std::string accType)
{
    AccountType=accType;
}
string Account::getAccountType()
{
    return AccountType;
}
void Account::setBalance(double Bal)
{
    Balance=Bal;
}
double Account::getBalance()
{
    return Balance;
}
void Account::setBranchName(std::string bN)
{
     BranchName=bN;
}
string Account::getBranchName()
{
    return  BranchName;
}
bool Account::Deposit(double amt)//depositing in account
{
    if(amt<0)//-ve
        return false;
    Balance+=amt;
    return true;
}

bool Account::Withdraw(double amt)//withdrawing in account
{
    if(amt<0|| amt > Balance)
        return false;
    Balance-=amt;
    return true;
}
void Account::setDate(int d)
{ 

    date=d;
}
int Account::getDate()
{
    if(date<=0||date>31)
        return -1;
    else 
    return date;
}
void Account::Display()
{
    cout<<getHolderName()<<setw(15)<<getHolderID()<<setw(20)<<getAccountId()<<setw(20)<<getAccountType()<<setw(12)<<getBalance()<<setw(10)<<endl;
}

//******** Bank Management System *****************//

in the bank management system .cpp :

#include "stdafx.h"
#include"iostream"
#include<fstream>
#include<string>
#include<vector>
#include"BS.h"
#include"iomanip"
using namespace std;



    vector<Branches>BranchList;//List of branches
    vector<Holder>HolderList;//list of Holders
    vector<Account>AccountList;//List of accounts
    void BranchInfo()
    {

        string BN;
    long BId;
    string Baddress;
    long BTel;
    int HLine;
    bool cont=false; 
    vector<Branches>::iterator i ;
label1: 
     system("cls");
     cout<<"Enter Branch Name \n";
          cin>>BN;
          for(i=BranchList.begin();i!=BranchList.end();i++)
             {
                 Branches B=*i;
                 string braName =  B.getBranchName();
                 if( braName == BN)
                 {
                     cont=true;
                 }
             }
     cout<<"Enter Branch Id \n";
          cin>>BId;

     cout<<"Enter Branch Address \n";
     cin>>Baddress;
     cout<<"Enter Branch Telephone \n";
         cin>>BTel;
     cout<<"Enter Branch HotLine \n";
         cin>>HLine;

             if(cont)

             {
                 cout<<"Error The name is there.\n";
             }
             else{
                BranchList.push_back(Branches(BN,BId,Baddress,BTel,HLine));
             }

       cout<<"Do you need to add new branch (Y/N) ?" ;
           char add = 'n' ;
       cin>> add ;
       if ( add == 'Y' || add == 'y')
           goto label1;

    }
    void DisplayBranchInfo()
    {
        system("cls");
      vector<Branches>::iterator i ;
      cout<<"Branch Name"<<setw(13)<<"Branch ID"<<setw(20)<<"Branch Address"<<setw(20)<<"Branch Telephone" <<setw(16)<<"Branch HotLine"<<endl;
      for(i=BranchList.begin();i!=BranchList.end();i++)
      {
          Branches  bran = *i;
          bran.Display();
      }
    }

    void UpdateBranchInfo()
    {
        system("cls");
        int count=0;
        int choice;
        vector<Branches>::iterator i ;
        string Bn;
        bool cont=false;
        DisplayBranchInfo();
        cout<<"Enter Branch Name u want to update in...";
        cin>>Bn;

        for(i=BranchList.begin();i!=BranchList.end();i++,count++)
        {   
            Branches b = *i ;

            string tmp=b.getBranchName();
            if(tmp==Bn)
            {

                cout<<"Press 1 to Update Name :)";
                cout<<"Press 2 to Update Address :)";
                cout<<"Press 3 to Update Telephone :)";
                cout<<"Press 4 to Update Hotline :)";
                cin>>choice;

                if(choice==1)
                {
                    string n;
                    cout<<"Enter value for Updating";
                    cin>>n;
                    vector<Branches>::iterator y ;
      for( y=BranchList.begin();y!=BranchList.end();y++)
{
     Branches bran= *y ;
       string a = bran.getBranchName();
        if( n == a )
           cont = true;


}

if(cont)
cout<<"Invalid, entering an existed value \n \n";//if it is repeated

else
{
b.setBranchName(n);
b.Display();
Branches Nbranch = Branches(n,b.getBranchId(),b.getBranchAdrress(),b.getBranchTel(),b.getHotline())  ;
BranchList.erase(BranchList.begin()+count) ;//You should erase the brach first then add it again 

BranchList.insert(BranchList.begin()+count,Nbranch) ; 

  }
break ;  // Break here to terminate loop else it will pass through other conditions causing debug error :)
}
else if( choice == 2 )
 {
        string n;
        cout<<"Enter the address u want for Updating";
            cin>>n;
            b.setBranchAddress(n);
            b.Display();
Branches Nbranch = Branches(b.getBranchName(),b.getBranchId(),n,b.getBranchTel(),b.getHotline())  ;

        BranchList.erase(BranchList.begin()+count) ;

    BranchList.insert(BranchList.begin()+count,Nbranch) ; 
                        break;

                }

else if( choice == 3 )
 {
     long n;
      cout<<"Enter the telephone u want for Updating";
            cin>>n;
            b.setBranchTel(n);
            b.Display();
Branches Nbranch = Branches(b.getBranchName(),b.getBranchId(),b.getBranchAdrress(),n,b.getHotline())  ;

        BranchList.erase(BranchList.begin()+count) ; 

        BranchList.insert(BranchList.begin()+count,Nbranch) ;
                        break;
                }

    else if( choice == 4 )
    {
        int n;
      cout<<"Enter the Hotline u want for Updating";
                    cin>>n;
                    b.setHotLine(n);
                    b.Display();
Branches Nbranch = Branches(b.getBranchName(),b.getBranchId(),b.getBranchAdrress(),b.getBranchTel(),n)  ;

BranchList.erase(BranchList.begin()+count) ;

    BranchList.insert(BranchList.begin()+count,Nbranch) ; 
                        break;
        }

    else
    {
       cout<<"erroooooooooooooooooor aaaaaaaaaaaaaaah \n\n";
    }
}

        }
    }
    void EnterHolderInformation()
    {
        vector<Holder>::iterator j;
        vector<Branches>::iterator i ;
        string HName;
        string HAddress;
        int HId;
        int SSN;
        long HTel;
        string Nationality;
        string BranchName;
        bool cont=false;
        bool check=false;

label1:
        system("cls");

        cout<<"Enter Holder Name:\n\n";
        cin>>HName;
        cout<<"Enter Holder address\n\n";
        cin>>HAddress;
        cout<<"Enter Holder ID";
        cin>>HId;
        cout<<"\n\nEnter the social security Number";
        cin>>SSN;
        for(j=HolderList.begin();j!=HolderList.end();j++)
        {
            Holder h= *j;
            int Id = h.getID();
            int ssn=h.getSSN();
            if( Id == HId&&ssn==SSN)//not repeated
              check=true;
        }


        cout<<"\n\nEnter your telephone\n\n";
        cin>>HTel;
        cout<<"\n\nEnter your Nationality\n\n";
        cin>>Nationality;
        cout<<"\n\nenter the branch you want";
        cin>>BranchName;
        for(i=BranchList.begin();i!=BranchList.end();i++)
        {
              Branches bran=*i;
              string bn=bran.getBranchName();
               if( bn == BranchName)
                 {
                     cont=true;
                 }

        }
        if(cont && !check)
        {
HolderList.push_back(Holder(HName,HAddress,HId,SSN,HTel,Nationality,BranchName));
        }
        else
    cout<<"\n\n error !!!!!! take care, you're entering either invalid branch Name or invalid ID";
        cout<<"Do you need to add new Holder (Y/N) ?" ;
           char add = 'n' ;
       cin>> add ;
       if ( add == 'Y' || add == 'y')

           goto label1;


    }
    void DisplayHolderInfo()
    {
        vector<Holder>::iterator j;
      cout<<"holder name:"<<setw(13)<<"holder ID:"<<setw(20)<<"holder address"<<setw(20)<<"holder SSN"<<setw(20)<<"holder teleophone"<<setw(16)<<"branch name:"<<setw(16)<<"holder nationality"<<endl;
      for(j=HolderList.begin();j!=HolderList.end();j++)
      {
          Holder  Hol = *j;
          Hol.Display();
      }
    }
    void SearchforHolder()
    {    vector<Holder>::iterator j;
    string HN;
        int choice;
        cout<<"\n\npress 1 to search for Name\n\n";
        cout<<"\n\npress 2 to search for ID\n\n";
        cout<<"\n\npress 3 to search for Branch\n\n";
        cin>>choice;
        if(choice==1)
        {
            cout<<"enter name to search";
            cin>>HN;
            for(j=HolderList.begin();j!=HolderList.end();j++)
            {
                Holder h=*j;
                string hn=h.getName();
    if(HN==hn)
    {
cout<<h.getName()<<"  "<<h.getAddress()<<"  "<<h.getBranchName()<<"  "<<h.getID()<<"  "<<h.getNationality()<<"  "<<h.getSSN()<<"  "<<h.getTelephoneNo();
                }



            }

        }
        else if(choice==2)
        {
            string add;
            cout<<"enter the address to search";
            cin>>add;
for(j=HolderList.begin();j!=HolderList.end();j++)
    {
                Holder h=*j;
                string hadd=h.getAddress();
    if(add==hadd)
    {
    cout<<h.getName()<<"  "<<h.getAddress()<<"  "<<h.getBranchName()<<"  "<<h.getID()<<"  "<<h.getNationality()<<"  "<<h.getSSN()<<"  "<<h.getTelephoneNo();
                }



            }
        }
        else if(choice==3)
        {
          string branch;
            cout<<"enter the branch to search";
            cin>>branch;
            for(j=HolderList.begin();j!=HolderList.end();j++)
            {
                Holder h=*j;
                string bran=h.getBranchName();
    if(branch==bran)
    {
cout<<h.getName()<<"  "<<h.getAddress()<<"  "<<h.getBranchName()<<"  "<<h.getID()<<"  "<<h.getNationality()<<"  "<<h.getSSN()<<"  "<<h.getTelephoneNo();
                }



            }
        }


    }
    void DisplayBranchAccountHolders()
    {
        vector<Holder>::iterator j;
        string BranchName;
        cout<<"Enter the Branch Name u want to display account holders of ";
        cin>>BranchName;
        for(j=HolderList.begin();j!=HolderList.end();j++)
        {
            Holder h=*j;
            string bran=h.getBranchName();
            if(BranchName==bran)
            {
                h.Display();
                cout<<"\n\n";
            }
            else 
                cout<<"\n\n Invalid Branch Name";




        }


    }
    void UpdateHolderInformation()
    {    vector<Branches>::iterator i;
         vector<Holder>::iterator j;
        int choice;
        bool cont=false;
        bool check=false;
         string HN;
         int count=0;
         system("cls");
        cout<<"Enter the Holder u want to update \n\n";
          cin>>HN;
        for(j=HolderList.begin();j!=HolderList.end();j++,count++)
        {
            Holder h=*j;
            string n=h.getName();
            if(HN==n)
            {
                cout<<"\n\nPress 1 to Update Name\n\n";
                cout<<"\n\nPress 2 to Update address\n\n";
                cout<<"\n\npress 3 to Update Telephone Number\n\n";
                cout<<"\n\npress 4 to Update Branch\n\n";
                cin>>choice;
if(choice==1)
  {
     string n;
      cout<<"\n\nEnter value for Updating\n\n";
                    cin>>n;
                    vector<Holder>::iterator y ;
         for( y=HolderList.begin();y!=HolderList.end();y++)
            {
                Holder Hol= *y ;
                     string a = Hol.getName();
                  if( n == a )
                cont = true;


            }
            if(cont)
        cout<<"Invalid, entering an existed value \n \n";
            else
                 {
                h.setName(n);
                h.Display();

Holder  NHolder = Holder(n,h.getAddress(),h.getID(),h.getSSN(),h.getTelephoneNo(),h.getNationality(),h.getBranchName());

HolderList.erase(HolderList.begin()+count) ; // You should erase the Holder first then add it again 

HolderList.insert(HolderList.begin()+count,NHolder) ;

                    }


              break ;
            }

else if( choice == 2 )
    {
        string n;
    cout<<"\n\nEnter the address u want for Updating\n\n";
                    cin>>n;
                    h.setAddress(n);
                    h.Display();

Holder  NHolder = Holder(h.getName(),n,h.getID(),h.getSSN(),h.getTelephoneNo(),h.getNationality(),h.getBranchName());

HolderList.erase(HolderList.begin()+count) ; // You should erase the Holder first then add it again 

HolderList.insert(HolderList.begin()+count,NHolder) ; 
                        break ;

                }

    else if( choice == 3 )
    {
        long n;
    cout<<"\n\nEnter the telephone u want for Updating\n\n";
                    cin>>n;
                h.setTelephoneNo(n);
                    h.Display();

Holder  NHolder = Holder(h.getName(),h.getAddress(),h.getID(),h.getSSN(),n,h.getNationality(),h.getBranchName());

HolderList.erase(HolderList.begin()+count) ; // You should erase the Holder first then add it again 

    HolderList.insert(HolderList.begin()+count,NHolder) ; 
                break ;

                }
else if (choice==4)
{

    string n;
    cout<<"\n\nEnter the Branch Name u want for Updating\n\n";
                    cin>>n;
        for(i=BranchList.begin();i!=BranchList.end();i++)
        {
                Branches bran=*i;
        string bn=bran.getBranchName();
        if(n==bn)//it is found or entering an existed value
                {
                    cont=true;
                    check =true;


                        }



                    }
        if(cont&&!check)
                {
        h.setBranchName(n);
         h.Display();

 Holder  NHolder = Holder(h.getBranchName(),h.getAddress(),h.getID(),h.getSSN(),h.getTelephoneNo(),h.getNationality(),n);

HolderList.erase(HolderList.begin()+count) ; // You should erase the Holder first then add it again 

HolderList.insert(HolderList.begin()+count,NHolder) ; 


                    }

        else 
              {
             cout<<"\n\nInvalid Branch Name....\n\n";

         }

                }



        }
    }
}
    void EnterAccountInformation()
    {
        vector<Branches>::iterator i ;
        vector<Holder>::iterator j;
        vector<Account>::iterator k;
         string HNme;
         int HId;
       double Bal;
        string BranNme;
        int AccId;
       string AccType; 
       bool cont=false;
       bool check=false;
       bool found=false;

label1 :
        system("cls");
       cout<<"\n\nEnter the Holder's Name\n\n";
       cin>>HNme;

       cout<<"\n\nEnter Holder's ID";
       cin>>HId;
       for(j=HolderList.begin();j!=HolderList.end();j++)
       {
           Holder Hol=*j;
           string n=Hol.getName();
           int id=Hol.getID();
           if(HNme==n&&HId==id)//it is found
           {
             found =true;
           }
       }
       cout<<"\n\nEnter the Holder's Balance\n\n";
       cin>>Bal;
        //check for Branch Name to make sure if it already exists
       //check for account Id to make sure it is not repeated
       cout<<"\n\nEnter the Branch Name u want to put the account in\n\n";
       cin>>BranNme;
       for(i=BranchList.begin();i!=BranchList.end();i++)
        {
            Branches b=*i;
            string BN=b.getBranchName();
            if(BranNme==BN)
                cont=true;
       }
        cout<<"\n\nEnter the account ID\n\n";
        cin>>AccId;
        for(k=AccountList.begin();k!=AccountList.end();k++)
        {
            Account acc=*k;
            int id=acc.getAccountId();
            if(AccId==id)
                check=true;//it shouldn't be repeated
        }


        cout<<"\n\nEnter the account type\n\n";
        cin>>AccType;
        if(cont&&!check&&found)//if branch name is found and accid is not repeated
            AccountList.push_back(Account(HNme,HId,Bal,BranNme,AccId,AccType));
        else//error if one of these conditions is wrong
            cout<<"\n\n errrrrrooooorrrrrrr :@\n\n";

            cout<<"\n\nDo you need to add new account (Y/N) ?\n\n" ;
           char add = 'n' ;
       cin>> add ;
       if ( add == 'Y' || add == 'y')

           goto label1;



    }

    void DisplaySpecificAccount()
    {    

        vector<Account>::iterator k;
       int accNum;
        cout<<"Enter a specific account u want to Display";
        cin>>accNum;
        for(k=AccountList.begin();k!=AccountList.end();k++)
        {
            Account acc=*k;
            int acN=acc.getAccountId();
            if(accNum==acN)

            {acc.Display();}

        }

    }
     void DisplayHolderAccounts()
     {
         system("cls");
         vector<Account>::iterator k;
         cout<<"Holder Name"<<setw(15)<<"Holder ID"<<setw(20)<<"Account ID"<<setw(20)<<"Account Type"<<setw(12)<<"Balance"<<endl;
         for(k=AccountList.begin();k!=AccountList.end();k++)
         {
             Account acc=*k;
             acc.Display();
         }
     }



 void deleteBranch()
{
    vector<Branches>::iterator i;
     string branchName ;
    cout<<"Enter the branch name you need to delete : " ;
    cin>>branchName;
    int d = -1 ;
     for(i= BranchList.begin() ; i != BranchList.end(); i++,d++ )  
    {

        Branches b = *i;
        if(branchName == b.getBranchName())
        {
           BranchList.erase(i );
           break;
        }
    }
}


void DisplaySpecificBankAccounts()
{
     system("cls");
    vector<Branches>::iterator i ;
    vector<Account>::iterator k;
    string BN;
    bool cont=false;
    cout<<"Enter the Branch Name u want to display it's accounts";
    cin>>BN;
    for ( i= BranchList.begin() ; i != BranchList.end() ; i++)
    {
        Branches b=*i;
        string n=b.getBranchName();
        if(n==BN)//this branch name is found
        cont=true;



    }
    if(cont)
    {
        for(k=AccountList.begin();k!=AccountList.end();k++)
        {
            Account acc=*k;
            string f=acc.getBranchName();
            if(f==BN)
                acc.Display();


        }
    }
    else
        cout<<"\n\nInvalid Branch Name :@\n\n";



}
void Deposit_in_specific_account()
{ 
     system("cls");
    vector<Account>::iterator k;
    int acc;
    double amt;//amount to be deposited in account
    bool cont=false;
    cout<<"\n\nEnter the account u want to deposit in\n\n";
    cin>>acc;
    cout<<"\n\nEnter the amount you want to deposit\n\n";
    cin>>amt;
    for(k=AccountList.begin();k!=AccountList.end();k++)
    {
        Account ac=*k;
        int a=ac.getAccountId();
        if(acc==a)//this id is found
        {   cont=true;
        if(ac.Deposit(amt))
                cout<<":) New balance is : "<<ac.getBalance();
            else 
                cout<<"\n\n Invalid Amount :(\n\n";
        }
        break;

    }
    if(!cont) 
            cout<<"\n\nsorryyyyyyyyyyyyy ,Invalid ID \n\n";
}
void Withdraw_from_specific_account()
{ 
     system("cls");
    vector<Account>::iterator k;
    int acc;
    double amt;//amount to be deposited in account
    bool cont=false;
    cout<<"\n\nEnter the account u want to withdraw from\n\n";
    cin>>acc;
    cout<<"\n\nEnter the amount you want to withdraw\n\n";
    cin>>amt;
    for(k=AccountList.begin();k!=AccountList.end();k++)
    {
        Account ac=*k;
        int a=ac.getAccountId();
        if(acc==a)//this id is found
        {   cont=true;
        if(ac.Withdraw(amt))
        {
                cout<<":) New balance is : "<<ac.getBalance();
        double n=ac.getBalance();
        ac.setBalance(n);
        }

            else 
                cout<<"\n\n Invalid Amount :(\n\n";
        }

    }
    if(!cont) 
            cout<<"\n\nsorryyyyyyyyyyyyy ,Invalid ID \n\n";
}
void readAccount()
{
    string line;
    string account;

  string holderName ;
  int holderID ;
  double balance ;
  string branchName ;
  int accountID ;
  string accountType ;

  ifstream myfile ("Account.txt");
  if (myfile.is_open())
  {
    while ( myfile.good() )
    {
      getline (myfile,line);
      if (line != "")
      {
          cout << line << "\n\n";
          int n = line.find(",") ;

          string temp ;
          string newln = line.substr(0,n);
          holderName = newln ;
          cout<<"Holder Name : "<< holderName << "\n";

          //------------------

          newln = line.substr(n+1,line.length());
          n = newln.find(",");
          account = newln.substr(0,n);
          char val [30] ;
          for (int i = 0 ; i < account.length() ; i++)
            val[i] = account.at(i) ;
          holderID = atol(val);
          cout <<"Holder ID : " << holderID <<"\n";

          //---------------------

          for (int ii = 0 ; ii < account.length() ; ii++)
             val[ii] = ' ' ;
          temp = newln.substr( n+1 , newln.length());
          n = temp.find(",");
          account = temp.substr(0,n);
          for (int j = 0 ; j < account.length() ; j++)
            val[j] = account.at(j) ;
          balance = atol(val) ;
          cout <<"Account Balance : "<<balance <<"\n";

          //--------------------------

          newln = temp.substr(n+1 , temp.length());
          n = newln.find(",");
          account = newln.substr(0,n);
          branchName = account ;
          cout<<"Branch Name : " << branchName<<"\n" ;

          //-------------------------

          for (int jj = 0 ; jj < account.length() ; jj++)
            val[jj] = ' ' ;
          temp = newln.substr(n+1 , newln.length());
          n= temp.find(",");
          account = temp.substr(0,n);

          for (int k = 0 ; k < account.length() ; k++)
            val[k] = account.at(k) ;

          accountID  = atol(val) ;

          cout<<"Account ID : " << accountID <<"\n";

          for (int kk = 0 ; kk < account.length() ; kk++)
            val[kk] = ' ' ;

          //---------------------------------------

          newln = temp.substr(n+1,temp.length());
          n = newln.find(",");
          account = newln.substr(0,n);
          accountType = account ;
          cout<<"Account Type : " << accountType <<"\n\n" ;
          AccountList.push_back(Account(holderName,holderID,balance,branchName,accountID,accountType));
      }
    }
    myfile.close();
  }

  else cout << "Unable to open file"; 
}
void writeAccount()
{
    vector<Account>::iterator k;
    ofstream myfile;
    myfile.open ("Account.txt");
    //Iterator on the vector and make that
    for(k=AccountList.begin();k!=AccountList.end();k++)
    {
          Account acc = *k ;
     myfile<<acc.getHolderName()<<","<<acc.getHolderID()<<","<<endl;
    myfile << "Reem,1,10000,Cairo,1,ATM.\n";
    myfile << "Ahmed,2,20000,Giza,2,ATM.\n";
    myfile << "Yousef,3,30000,Alex,3,ATM.\n";
    myfile.close();
    }
}
void readBranch()
{
    string line;

  string branchName ;
  long branchID ;
  string branch;
  string branchAddress ;
  long branchTel ;
  int branchHotLine ;

  ifstream myfile ("Branch.txt");
  if (myfile.is_open())
  {
    while ( myfile.good() )
    {
      getline (myfile,line);
      if (line != "")
      {
          cout << line << "\n\n";
          int n = line.find(",") ;

          string temp ;
          string newln = line.substr(0,n);
          branchName = newln ;
          cout<<"Branch Name : "<< branchName << "\n";

          //------------------

          newln = line.substr(n+1,line.length());
          n = newln.find(",");
          branch = newln.substr(0,n);
          char val [30] ;
          for (int i = 0 ; i < branch.length() ; i++)
            val[i] = branch.at(i) ;
          branchID = atol(val);
          cout <<"Branch ID : " << branchID <<"\n";

          //---------------------

          for (int ii = 0 ; ii < branch.length() ; ii++)
             val[ii] = ' ' ;
          temp = newln.substr( n+1 , newln.length());
          n = temp.find(",");
          branchAddress = temp.substr(0,n);
          cout <<"Branch Address : "<<branchAddress <<"\n";

          //--------------------------

          newln = temp.substr(n+1 , temp.length());
          n = newln.find(",");
          branch = newln.substr(0,n);

          for (int j = 0 ; j < branch.length() ; j++)
            val[j] = branch.at(j) ;
          branchTel = atol(val) ;
          cout<<"Branch Telephone : " << branchTel<<"\n" ;

          //-------------------------

          for (int jj = 0 ; jj < branch.length() ; jj++)
            val[jj] = ' ' ;
          temp = newln.substr(n+1 , newln.length());
          n= temp.find(",");
          branch = temp.substr(0,n);

          for (int k = 0 ; k < branch.length() ; k++)
            val[k] = branch.at(k) ;

          branchHotLine  = atol(val) ;

          cout<<"Branch HotLine : " << branchHotLine<<"\n\n";

          for (int kk = 0 ; kk < branch.length() ; kk++)
            val[kk] = ' ' ;
          BranchList.push_back(Branches(branchName,branchID,branchAddress,branchTel,branchHotLine));
      }
    }
    myfile.close();
  }

  else cout << "Unable to open file"; 
}
void writeBranch()
{
    vector<Branches>::iterator i;
    ofstream myfile;
    myfile.open ("Branch.txt");
    for(i=BranchList.begin();i!=BranchList.end();i++)
    {
       Branches bra = *i ;
       myfile<<bra.getBranchId()<<","<<bra.getBranchName()<<","<<endl;
    myfile << "Reem,1,Cairo,123445,57657.\n";
    myfile << "Ahmed,2,Giza,111111,22334.\n";
    myfile << "Yousef,3,Alex,999999,12345.\n";
    myfile.close();
    }

}

void readHolder()
{
    string line;
    string holder;

  string holderName ;
  string holderAddress ;
  int holderID ;
  int SSN ;
  long TelephoneNo ;
  string Nationality ;
  string branchName ;

  ifstream myfile ("Holder.txt");
  if (myfile.is_open())
  {
    while ( myfile.good() )
    {
      getline (myfile,line);
      if (line != "")
      {
          cout << line << "\n\n";
          int n = line.find(",") ;

          string temp ;
          string newln = line.substr(0,n);
          holderName = newln ;
          cout<<"Holder Name : "<< holderName << "\n";

          //------------------

          newln = line.substr(n+1,line.length());
          n = newln.find(",");
          holder = newln.substr(0,n);
          holderAddress = holder ;
          cout <<"Holder Address : " << holderAddress <<"\n";

          //---------------------


          temp = newln.substr( n+1 , newln.length());
          n = temp.find(",");
          holder = temp.substr(0,n);
          char val [30] ;
          for (int i = 0 ; i < holder.length() ; i++)
            val[i] = holder.at(i) ;
          holderID = atol(val);
          cout <<"Holder ID : "<<holderID <<"\n";

          //--------------------------
          for (int ii = 0 ; ii < holder.length() ; ii++)
             val[ii] = ' ' ;
          newln = temp.substr(n+1 , temp.length());
          n = newln.find(",");
          holder = newln.substr(0,n);

          for (int j = 0 ; j < holder.length() ; j++)
            val[j] = holder.at(j) ;
          SSN = atol(val) ;
          cout<<"Holder SSN : " << SSN<<"\n" ;

          //-------------------------

          for (int jj = 0 ; jj < holder.length() ; jj++)
            val[jj] = ' ' ;
          temp = newln.substr(n+1 , newln.length());
          n= temp.find(",");
          holder = temp.substr(0,n);

          for (int k = 0 ; k < holder.length() ; k++)
            val[k] = holder.at(k) ;

          TelephoneNo  = atol(val) ;

          cout<<"Holder Telephone : " << TelephoneNo<<"\n";

          for (int kk = 0 ; kk < holder.length() ; kk++)
            val[kk] = ' ' ;

          //--------------------------------------
          newln = temp.substr(n+1, temp.length());
          n= newln.find(",");
          Nationality = newln.substr(0,n);
          cout<<"Holder Nationality : " << Nationality <<"\n";

          //-----------------------------------
          temp = newln.substr(n+1, newln.length());
          n= temp.find(",");
          branchName = temp.substr(0,n);
          cout<<"Branch Name : " << branchName <<"\n\n" ;

          //HolderList.push_back(Holder(holderName,holderAddress,holderID,SSN,TelephoneNo,Nationality,BranchName));
      }
    }
    myfile.close();
  }

  else cout << "Unable to open file"; 
}

int _tmain(int argc, _TCHAR* argv[])
{   
    int choice;

label1 :
    cout<<"                **************Welcome**************\n\n";
cout<<"\n\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n";
    cout<<"* Press 1 for Add Branch                                  **\n";
    cout<<"* Press 2 for Display Branch                              ***\n";
    cout<<"* Press 3 to update branch                                ****\n";
    cout<<"* Press 4 to delete Branch                                *****\n";
    cout<<"* press 5 to enter Holder info                            ******\n";
    cout<<"* press 6 to Display Holder info                          *******\n";
    cout<<"* press 7 to seach for specific Holder                    ********\n";
    cout<<"* press 8 to Display account Holders for specific branch  *********\n";
    cout<<"* press 9 to Update Holder Information                    **********\n";
    cout<<"* press 10 to Enter Account Information                   ***********\n";
    cout<<"* press 11 to Display specific account information        *************\n";
    cout<<"* Press 12 to Display Holder Accounts                     ***********\n";
    cout<<"* press 13 to Display specific branch accounts            **********\n";
    cout<<"* press 14 to Deposit in specific Account                 *********\n";
    cout<<"* press 15 to withdraw from specific Account              ********\n";
    cout<<"* press 16 to read  account details from file             *******\n";
    cout<<"* press 17 to write from Account file                     ******\n";
    cout<<"* press 18 to read Branch details from file               *****\n";
    cout<<"* press 19 to write  from Branch  file                    ****\n";
    cout<<"* press 20 to read from holder file                       ***\n";
    cout<<"* press 21 to exit                                        **\n";
    cout<<"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n";





    cin>>choice;
   if ( choice == 1 )
   {
       BranchInfo();
       goto label1 ;
   }
   else if ( choice == 2 ) 
   {
       DisplayBranchInfo();
       goto label1 ;
   }
   else if(choice==3)
   {
     UpdateBranchInfo();
      goto label1 ;
   }
    else if(choice==4)
   {
     deleteBranch();
     goto label1;
   }
   else if(choice==5)
   {
       EnterHolderInformation();
       goto label1;
   }
   else if(choice==6)
   {
       DisplayHolderInfo();
       goto label1;
   }
 else if(choice==7)
   {
       SearchforHolder();
       goto label1;
   }
   else if (choice==8)
   {
     DisplayBranchAccountHolders();
     goto label1;
   }
   else if(choice==9)
   {
      UpdateHolderInformation();
       goto label1;
   }
   else if(choice==10)
   {
       EnterAccountInformation();
       goto label1;
   }
   else if(choice==11)
   {
       DisplaySpecificAccount();
       goto label1;
   }
   else if(choice==12)
   {
       DisplayHolderAccounts();
       goto label1;

   }
   else if(choice==13)
   {
       DisplaySpecificBankAccounts();
       goto label1;
   }
   else if(choice==14)
   {
       Deposit_in_specific_account();
       goto label1;
   }
   else if(choice==15)
   {
     Withdraw_from_specific_account();
     goto label1;
   }
   else if(choice==16)
   {
        readAccount();
        goto label1;

   }
   else if(choice==17)
   {
       writeAccount();
       goto label1;
   }
   else if (choice==18)
   {
       readBranch();
       goto label1;
   }
   else if(choice==19)
   {
       writeBranch();
       goto label1;
   }
   else if(choice==20)
   {
       readHolder();
       goto label1;
   }
   else if(choice==21)
   {

       goto end;
   }

end:
    return 0;
}
 else if(choice==7)
   {
       SearchforHolder();
       goto label1;
   }
   else if (choice==8)
   {
     DisplayBranchAccountHolders();
     goto label1;
   }
   else if(choice==9)
   {
      UpdateHolderInformation();
       goto label1;
   }
   else if(choice==10)
   {
       EnterAccountInformation();
       goto label1;
   }
   else if(choice==11)
   {
       DisplaySpecificAccount();
       goto label1;
   }
   else if(choice==12)
   {
       DisplayHolderAccounts();
       goto label1;

   }
   else if(choice==13)
   {
       DisplaySpecificBankAccounts();
       goto label1;
   }
   else if(choice==14)
   {
       Deposit_in_specific_account();
       goto label1;
   }
   else if(choice==15)
   {
     Withdraw_from_specific_account();
     goto label1;
   }
   else if(choice==16)
   {
        readAccount();
        goto label1;

   }
   else if(choice==17)
   {
       writeAccount();
       goto label1;
   }
   else if (choice==18)
   {
       readBranch();
       goto label1;
   }
   else if(choice==19)
   {
       writeBranch();
       goto label1;
   }
   else if(choice==20)
   {
       readHolder();
       goto label1;
   }
   else if(choice==21)
   {

       goto end;
   }

end:
    return 0;
}


i'm still working on the project and complete general functions and improving in my code

Edited 3 Years Ago by ~s.o.s~: formatting

Comments
Epic fail.
This question has already been answered. Start a new discussion instead.