taz_beginner
November 15th, 2006, 06:22 AM
This program is using classes to perform various banking functions(i am a beginner)
how can i make it withdraw client money and display all clients account balances?
// bank account program
#include <iostream.h>
const m=50;
class BANK
{
char name[10],Atype[10];
int accountno[m],count;
float balance[m],amount[m];
public:
void CNT(void){count=0;} //initialising count
void getitem(void);
void displayAll(void);
void deposit(void);
void remove(void);
void displaySum(void);
};
//===================================================
void BANK :: getitem(void) //creates an account
{
cout<<" \nEnter your name please\n";
cin>>name[count];
cout<<" \nEnter the type of account you'd like,\n";
cout<<" \nEither a \n1. current,\n2. Savings or \n3. Fixed account\n";
cin>>Atype;
cout<<" \nEnter account number: ";
cin>>accountno[count];
}
void BANK :: deposit(void) // depositting amounts
{
cout<<" \nPlease enter your account number\n";
cin>> accountno[count];
cout<<" \nPlease Enter the amount you are depositting\n";
cin>>amount[count];
cout<<"\n The amount has been creditted to your account\n";
cout<<"\n Have a good day\n";
count++;
}
void BANK :: displaySum(void) //displays amount
{
float balance = 0;
for (int i=0; i<count; i++)
balance = balance + amount[i];
cout<<"\n You have :" <<balance;
}
/*void BANK :: remove(void) //withdrawals
int a;
cout<<" \nEnter Account number";
cin>>accountno;
cout<<"\n You have :"<<balance;
cout<"\n Enter amount to withdrawn";
cin>>a;
for (int i=0; i<count; i++)
if (a<balance)
{
balance = balance-a
}
cout<<" Final balance: "<<balance*/
void BANK ::displayAll(void)
{
cout<<"\nName Balance\n";
for(int i=0; i<count; i++)
{
cout<<"\n" <<name[i];
cout<<"\n" <<balance[i];
cout<<"\n";
}
}
//================================================================
int main()
{
BANK client;
client.CNT();
int x;
do
{
cout<<"\n-----------------------------------------------------";
cout<<"\n You can do the following;"
<<" Enter appropriate number\n";
cout<<"\n1 : Add a client ";
cout<<"\n2 : Deposit amounts ";
cout<<"\n3 : Display depositted amount ";
cout<<"\n4 : Withdraw amounts ";
cout<<"\n5 : Display client balance ";
cout<<"\n6 : Quit";
cout<<"\n\n What would you like to do?";
cin>> x;
switch(x)
{
case 1 : client.getitem();break;
case 2 : client.deposit();break;
case 3 : client.displaySum();break;
case 4 : break;
case 5 : client.displayAll();break;
case 6 : cout<<" \nThis program was created by Taz,for more information visit www.taz.com\n";break;
default : cout<<" Please input a choice between 1 and 5\n";
}
} while (x!=6);
return 0;
}
eagerly awaiting a response,
how can i make it withdraw client money and display all clients account balances?
// bank account program
#include <iostream.h>
const m=50;
class BANK
{
char name[10],Atype[10];
int accountno[m],count;
float balance[m],amount[m];
public:
void CNT(void){count=0;} //initialising count
void getitem(void);
void displayAll(void);
void deposit(void);
void remove(void);
void displaySum(void);
};
//===================================================
void BANK :: getitem(void) //creates an account
{
cout<<" \nEnter your name please\n";
cin>>name[count];
cout<<" \nEnter the type of account you'd like,\n";
cout<<" \nEither a \n1. current,\n2. Savings or \n3. Fixed account\n";
cin>>Atype;
cout<<" \nEnter account number: ";
cin>>accountno[count];
}
void BANK :: deposit(void) // depositting amounts
{
cout<<" \nPlease enter your account number\n";
cin>> accountno[count];
cout<<" \nPlease Enter the amount you are depositting\n";
cin>>amount[count];
cout<<"\n The amount has been creditted to your account\n";
cout<<"\n Have a good day\n";
count++;
}
void BANK :: displaySum(void) //displays amount
{
float balance = 0;
for (int i=0; i<count; i++)
balance = balance + amount[i];
cout<<"\n You have :" <<balance;
}
/*void BANK :: remove(void) //withdrawals
int a;
cout<<" \nEnter Account number";
cin>>accountno;
cout<<"\n You have :"<<balance;
cout<"\n Enter amount to withdrawn";
cin>>a;
for (int i=0; i<count; i++)
if (a<balance)
{
balance = balance-a
}
cout<<" Final balance: "<<balance*/
void BANK ::displayAll(void)
{
cout<<"\nName Balance\n";
for(int i=0; i<count; i++)
{
cout<<"\n" <<name[i];
cout<<"\n" <<balance[i];
cout<<"\n";
}
}
//================================================================
int main()
{
BANK client;
client.CNT();
int x;
do
{
cout<<"\n-----------------------------------------------------";
cout<<"\n You can do the following;"
<<" Enter appropriate number\n";
cout<<"\n1 : Add a client ";
cout<<"\n2 : Deposit amounts ";
cout<<"\n3 : Display depositted amount ";
cout<<"\n4 : Withdraw amounts ";
cout<<"\n5 : Display client balance ";
cout<<"\n6 : Quit";
cout<<"\n\n What would you like to do?";
cin>> x;
switch(x)
{
case 1 : client.getitem();break;
case 2 : client.deposit();break;
case 3 : client.displaySum();break;
case 4 : break;
case 5 : client.displayAll();break;
case 6 : cout<<" \nThis program was created by Taz,for more information visit www.taz.com\n";break;
default : cout<<" Please input a choice between 1 and 5\n";
}
} while (x!=6);
return 0;
}
eagerly awaiting a response,