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");
}