OOP Chapter 4 Solve
Exercise : 5.1
#include <iostream>
#include <cstring>
using namespace std;
class BankAcntInfo
{
string name;
char
acnt_num[10];
char
acnt_type[10];
int blnc;
int tmp;
public:
BankAcntInfo()
{
blnc=0;
tmp =0;
Initial();
}
void
Initial(void);
void
Deposit(void);
void
Withdraw(void);
void
Info(void);
};
int main()
{
BankAcntInfo
Empl;
char ch;
while(ch!='E'
&& ch!='e')
{
cout
<<"\t\tD For Depositing value\n"<<
"\t\tW
For Withdraw \n"<<
"\t\tS
For Displaying Statement\n"<<
"\t\tE
To Exit\n"<<
"\n\n\t\tEnter your choice : ";
cin
>> ch;
switch(ch)
{
case 'd':
case 'D':
{
Empl.Deposit();
break;
}
case 'w':
case 'W':
{
Empl.Withdraw();
break;
}
case 'S':
case 's':
{
Empl.Info();
break;
}
}
}
}
void BankAcntInfo :: Initial( void )
{
cout <<
"Enter name of Account : ";
getline(cin,name);
cout <<
"Enter Account type : ";
cin >>
acnt_type;
cout <<
"Enter Account Number : ";
cin >>
acnt_num;
}
void BankAcntInfo :: Deposit( void )
{
cout <<
"Enter Deposit Amount for " << acnt_num << " Account
Number"<< "\nEnter value in taka : ";
cin >>
tmp;
blnc+=tmp;
cout <<
"Balance is = " << blnc << endl;
}
void BankAcntInfo :: Withdraw( void )
{
cout <<
"Enter Withdraw Amount for " << acnt_num << "
Account Number" << "\nEnter value in taka : ";
cin >>
tmp;
blnc -= tmp;
cout <<
"Balance is = " << blnc << endl;
}
void BankAcntInfo :: Info( void )
{
cout <<
"Showing bank statements : \nAccount name : " << name <<
"\nAccount type : " << acnt_type << "\nBalance is =
" << blnc << endl;
}
No comments:
Post a Comment