Hi, I'm new on this forum, but a friend directed me here to seek further assistance with a program I am trying to create. I have to create a program that can manage 10 bank accounts, one of which uses appropriate type definition to store the name, account number, balance of bank account, and so forth. It also has to be an array that records the details of the 10 bank accounts, in addition it also must have functions and procedures to update the bank accounts array.
The program has to allow the user to deposit or withdraw credit from accounts, and to be able to see the balance of a certain account. And if an account is set to zero, this would close the account. Other then that, I am also trying to make it so that if the user selects an incorrect choice, they must be told or offered a different option, if they deposit or withdraw, they have to enter a figure and the relevant account number, all of which gets displayed on screen.
I've created some code but have been busy with work and family quite alot recently which has forced me to neglect learning C++ (I have difficulty remembering topics and functions). At which point I gave it to my friend to try and assist me with the issue, but has in turn given me code that doesn't work with the program I use to create C++ programs with (Net beans). I would very much appreciate any other examples of bank account programs just so I can see exactly how such a program should operate and how it should work to perfect my own.
And yes, the program in question is just for personal use only, just to educate myself more on C++ .
Any assistance would be appreciated, thanks.
W.S.
:)
#include<iostream.h>
#include<string.h>
#include<process.h>
class details
{
public:
char *name;
int age;
char branch[50];
char city[40];
void getdetails()
{
name=new char[20];
cout<<endl<<endl<<"**********Customer Details*********** "<<endl;
cout<<" -------- ------- "<<endl;
cout<<"Enter Name: ";
cin>>name;
cout<<"Enter Age: ";
cin>>age;
cout<<"Enter Branch: ";
cin>>branch;
cout<<"Enter City: ";
cin>>city;
cout<<"______________________________________"<<endl<<endl;
}
};
class bank
{
public:
static int accnumber;
long balance;
details d;
void getdata();
bank transfermoney(bank);
void deposit();
void withdrawal();
void newaccount();
void viewaccdetails();
};
int bank::accno=0;
void main()
{
char ch;
static int i=0;
bank *a[10];
int x,amt,k,j;
clrscr();
do
{
cout<<endl<<endl<<"************MENU************"<<endl;
cout<<" ---- "<<endl;
cout<<"1.Create new account\n2.Deposit\n3.Withdraw\n4.Transfer credits\n5.View account details\n\n";
cout<<"Enter choice no.: ";
cin>>x;
switch(x)
{
case 1:
{
i++;
a[i]=new bank;
a[i]->newaccount();
break;
}
case 2:
{
cout<<"Enter account no.: ";
cin>>k;
a[k]->deposit();
break;
}
case 3:
{
cout<<"Enter account no.: ";
cin>>k;
a[k]->withdrawal();
break;
}
case 4:
{
cout<<"Enter the source and destination account nos.: ";
cin>>k>>j;
*a[j]=a[k]->transfermoney(*a[j]);
break;
}
case 5:
{
cout<<"Enter account no.: ";
cin>>k;
a[k]->viewaccdetails();
break;
}
}cout<<"\nDo you wish to continue[Press 'Y' to continue or 'N' to exit menu]: ";
cin>>ch;
}while(ch=='y'||ch=='Y');
}
bank bank::transfermoney(bank a)
{
long amt;
cout<<"Enter amount to be transferred: ";
cin>>amt;
a.balance=a.balance+amt;
if(balance<amt)
{
cout<<"\nInsufficient balance! Operation Cannot be performed!"<<endl<<endl;
}
else
{
balance=balance-amt;
}
return a;
}
void bank::withdrawal()
{
long amtdrawn;
cout<<"Enter amount to be withdrawn: ";
cin>>amtdrawn;
if(balance<amtdrawn)
cout<<"\nInsufficient balance! Operation Cannot be performed!"<<endl<<endl;
else
balance=balance-amtdrawn;
}
void bank::deposit()
{
long dep;
cout<<"Enter amount to be deposited: ";
cin>>dep;
balance+=dep;
}
void bank::newaccount()
{
accno++;
d.getdetails();
balance=0;
}
void bank::viewaccdetails()
{
cout<<endl<<endl<<"*********ASSIGNMENT BANK ACCOUNT DETAILS*********"<<endl;
cout<<" --- ---- ------- ------- "<<endl;
cout<<"Account no.: "<<accno<<endl;
cout<<"Name: "<<d.name<<endl;
cout<<"Branch: "<<d.branch<<endl;
cout<<"City: "<<d.city<<endl;
cout<<"Current Balance: "<<balance<<endl;
cout<<"_________________________________________"<<endl;
}