Hi,
I am trying to make a bank application that has two interfaces.One is the employee interface that lets employees to create an account and assign a IDnumber to each account(lets say the bank only accepts 100 accounts) and a balance for each account.
The employee can also close an account in the employee interface by entering the IDnumber.

Now in the clients interface the user can enter the IDnumber of an account and after searching the IDnumbers created by the employees it lets the user the deposit,withdraw or show the account information such as balance.

I am not sure how i can store the IDnumbers in an array and then use them for each operation.I am also wondering how I can make use of "typedef" in my code.

Here is my code.I would appriciate it if you help me with it. Thanks in advance.

//********************************CUSTOMER.h*****************//

#ifndef customer_h
#define customer_h

class Customer {

   private:
		int acno;
	float acc_bal;

   public:
	   Customer();

	void open();
	void close();
	void deposit();
	void withdraw();
	void disp();
};
//******************************Customer.cpp********************//

#include "Customer.h"
#include <iostream>

using std::cout;
using std::cin;

Customer::Customer() 
{              // constructor
  acc_bal = 0.00;
}

void Customer :: open()
{
	cout<<"New Account\n";
	cout<<"Enter the Account Number : ";
	cin>>acno;
	cout<<"Account balance : ";
	cout<<acc_bal;
}
void Customer :: close()
{
	cout<<"Close Account\n";
	cout<<"Enter the Account Number : ";
	cin>>acno;
	acc_bal = 0.00;
	cout<<"Account balance : ";
	cout<<acc_bal;
}
void Customer :: deposit()
{
	float more;
	cout <<"Depositing:\n";
	cout<<"Enter the Account Number : ";
	cin>>acno;
	cout<<"\nEnter the amount to deposit : ";
	cin>>more;
		if(more<= 0){
		cout<<"Operation is cancelled,Can't deposit zero or negative amount.";
		cout<<"\n New balance : ";
		cout<<acc_bal;
			}
		else if(more> 0)
			{
			acc_bal+=more;
			cout<<"\n New balance : ";
			cout<<acc_bal;
			}
		else
		{
		cout<<"\n ERROR";
		}
}
void Customer :: withdraw()
{
float amt;
	cout<<"Withdrwal\n";
	cout<<"Enter the Account Number : ";
	cin>>acno;
	cout<<"\nEnter the amount to withdraw : ";
	cin>>amt;
	if(amt<= 0){
		cout<<"Operation is cancelled,Can't Withdrwal zero or negative amount.";
		cout<<"\n New balance : ";
		cout<<acc_bal;
		}
	else if(amt> 0)
		{
			
			if (acc_bal < amt){
			cout<<"Operation is cancelled,Not enough Money in Account";
				cout<<"\n New balance : ";
				cout<<acc_bal;
				}
			else
				{
				acc_bal-=amt;
				}
			cout<<"\n New balance : ";
			cout<<acc_bal;
		}
			else
		{
		cout<<"\n ERROR";
		}

}
void Customer :: disp()
{
cout<<"Account Details";
cout<<"Enter the Account Number : ";
	cin>>acno;
cout<<"\nAccount Number               : "<<acno<< std::endl;
cout<<"\nBalance               : $"<<acc_bal<< std::endl;
}
//******************************Main.cpp*****************//

#include "Customer.h"
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

// main function , exectution starts here
void main(void)
{
int choice = 0;   
int choice2 = 0; 
Customer obj;
while (choice != 999)
{
    cout << "\nWelcome to XYZ  Bank!\n"  << endl;
         cout << "Please select one of following options(type 999 to quit)\n" << endl;
cout << "-Customer\n" << endl;
	
	cout << "1. Deposit\n" << endl;
	cout << "2. Withdraw\n" << endl;
	cout << "3. Display balance\n"<< endl;
	cout << "-Bank Employee\n" << endl;
	cout << "4. Open a new acc.\n" << endl;
	cout << "5. Close a new acc.\n" << endl;

         cin >> choice;
		switch(choice)
		{
	case 999 :obj.disp();
		cout<<"EXITING PROGRAM.\n";
		break;
	case 1: obj.deposit();
		break;
	case 2 : obj.withdraw();
		break;
	case 3: obj.disp();
		break;
	case 4: obj.open();
		break;
	case 5 : obj.close();
		break;
	default: cout<<"Illegal Option\n"<<endl;
		
}
}
system("PAUSE");
}

Users creating account number themselves is not a good approach. you must avoid it. Well you can add following in Customer class:

private:
static int IDs[100]; //to store IDs of employees of type int
static int employee_count; //to keep track how many have opened account

Using static keyword, only one copy of both will exist for all customer objects.And then to access an ID randomly, like you want to see ID of 3rd employee then in a member function you can write:

int emp_num;
cout<<"enter employee number: ";
cin>>emp_num;
cout<<arr[emp_num];

i hope this helps. And why do you want to use typedef? i think so that its used very lessly in c++

I don't really need employee number,I need clients ID numbers created get saved in an array and when a user wants to deposit then he or she needs to enter a valid ID number which exist in the array and deposit money to the account.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.