In this program we will create class of bank and enter A/C holder data and information about account also withdraw or deposit money by asking user.
The code is given below.
//Code Starts
#include<iostream>
#include<conio.h>
using namespace std;
struct coustomer{
char
name[50],address[100],cnic[13],mon[10],actype[100];
int
age,bal,acno,dep,draw,rem,ammount,x,day,year;
};
class bank{
private:
char
account,achold[100];
int
deposite,withdraw;
coustomer c;
public:
char setachold();
char
setaccount();
int
setdeposite();
int setdate();
int
setwithdraw();
char* getachold();
char getaccount();
int
getdeposite();
int
getwithdraw();
void display();
};
int main()
{
bank b;
b.display();
getch();
}
char bank::setachold()
{
cout<<"Enter
Account holder name : ";
cin.getline(c.name,50);
cout<<"Enter
"<<c.name<<"'s' age
: ";
cin>>c.age;
cout<<"Enter
"<<c.name<<"'s address : ";
cin>>c.address;
cout<<"Enter
"<<c.name<<"'s' CNIC : ";
cin>>c.cnic;
}
int bank::setdate()
{
cout<<"Please
enter date in following format dd/mm/yy"<<endl;
cout<<"Enter
Day : ";
cin>>c.day;
cout<<"Enter
month : ";
cin>>c.mon;
cout<<"Enter
year : ";
cin>>c.year;
}
char bank::setaccount()
{
cout<<"Enter
"<<c.name<<"'s account type : ";
cin>>c.actype;
cout<<"Enter
"<<c.name<<"'s account number : ";
cin>>c.acno;
cout<<"Enter
"<<c.name<<"'s balance in
"<<c.actype<<" account : ";
cin>>c.bal;
}
int bank::setdeposite()
{
cout<<"How
many amount you want to deposite in "<<c.acno<<" :
";
cin>>c.dep;
c.rem=c.bal+c.dep;
cout<<c.name<<"'s
new balance after depositing "<<c.dep<<" RS in account no
:"<<c.acno<<" === "<<c.rem<<endl;
}
int bank::setwithdraw()
{
cout<<"How
many amount you want to withdarw from "<<c.acno<<" :
";
cin>>c.draw;
if(c.draw>c.bal)
{
cout<<"You
don't have sufficient ammount to withdraw";
}
else{
c.ammount=c.rem-c.draw;
cout<<c.name<<"'s
new balance after withdraw of
"<<c.draw<<" RS from account no
:"<<c.acno<<" === "<<c.draw<<endl;;
}
}
char* bank::getachold()
{
return achold;
}
char bank::getaccount()
{
return account;
}
int bank::getdeposite()
{
return deposite;
}
int bank::getwithdraw()
{
return withdraw;
}
void bank::display()
{
bank b;
b.setachold();
b.setdate();
b.setaccount();
abc: cout<<"For
deposite press 1 and for withdraw Press 2 ";
cin>>c.x;
if(c.x==1)
{
b.setdeposite();
}
else if(c.x==2)
{
b.setwithdraw();
}
else{
cout<<"Invalid
Entry please re-enter"<<endl;
goto abc;
}
cout<<"
"<<endl;
}
//Code Ends
OUTPUT:
0 comments:
Post a Comment