// Bank accounting system
#include<iostream>
using namespace std;
class bank{
private:
int acno;
char name[30];
int bal;
char actype;
public:
void deposit(int);
int withdraw (int);
void opac();
void show_info();
};
void bank::opac(){
cout << "Enter A/C no.:";
cin >> acno;
cout <<"Enter name:";
cin >> name;
cout <<"Enter opening balance:";
cin >> bal;
cout <<"Enter account type (s/l/c)";
cin >> actype;
}
void bank::show_info(){
cout<<"A/C no :"<<acno<<endl;
cout<<"Name :"<<name<<endl;
cout<<"A/C type :"<<actype<<endl;
cout<<"Balance :"<<bal<<endl;
}
void bank::deposit(int amt){
bal+=amt;
}
int bank:: withdraw(int amt){
if(actype=='l'){
cout<<"Withdraw is not possible";
return 0;
}
else if (actype=='c'){
if(bal-amt<200){
cout<<"Minimum balance reached"<<endl;
return 0;
}
else{
bal=bal-amt;
return(bal);
}
}
else if(actype=='s'){
if(bal-amt<500){
cout<<"Minimum balance reached!"<<endl;
return 0;
}
else{
bal=bal-amt;
return(bal);
}
}
}
main(){
bank a;
int ch=0,amt;
cout<<"opening your account:"<<endl;
a.opac();
do{
cout<<"1. Show account details:"<<endl;
cout<<"2. withdraw from account:"<<endl;
cout<<"3. deposite to account :"<<endl;
cout<<"4. Exit "<<endl;
cout<<"Enter your choice:"<<endl;
cin>>ch;
if(ch==1)
a.show_info();
else if(ch==2){
cout<<" Enter amount to withdraw :";
cin>> amt;
cout<<"Rs."<<a.withdraw(amt)<<endl;
}
else if(ch==3){
cout << "Enter amount to deposite :";
cin >>amt;
a.deposit(amt);
}
}while(ch!=4);
return 0;
}
#include<iostream>
using namespace std;
class bank{
private:
int acno;
char name[30];
int bal;
char actype;
public:
void deposit(int);
int withdraw (int);
void opac();
void show_info();
};
void bank::opac(){
cout << "Enter A/C no.:";
cin >> acno;
cout <<"Enter name:";
cin >> name;
cout <<"Enter opening balance:";
cin >> bal;
cout <<"Enter account type (s/l/c)";
cin >> actype;
}
void bank::show_info(){
cout<<"A/C no :"<<acno<<endl;
cout<<"Name :"<<name<<endl;
cout<<"A/C type :"<<actype<<endl;
cout<<"Balance :"<<bal<<endl;
}
void bank::deposit(int amt){
bal+=amt;
}
int bank:: withdraw(int amt){
if(actype=='l'){
cout<<"Withdraw is not possible";
return 0;
}
else if (actype=='c'){
if(bal-amt<200){
cout<<"Minimum balance reached"<<endl;
return 0;
}
else{
bal=bal-amt;
return(bal);
}
}
else if(actype=='s'){
if(bal-amt<500){
cout<<"Minimum balance reached!"<<endl;
return 0;
}
else{
bal=bal-amt;
return(bal);
}
}
}
main(){
bank a;
int ch=0,amt;
cout<<"opening your account:"<<endl;
a.opac();
do{
cout<<"1. Show account details:"<<endl;
cout<<"2. withdraw from account:"<<endl;
cout<<"3. deposite to account :"<<endl;
cout<<"4. Exit "<<endl;
cout<<"Enter your choice:"<<endl;
cin>>ch;
if(ch==1)
a.show_info();
else if(ch==2){
cout<<" Enter amount to withdraw :";
cin>> amt;
cout<<"Rs."<<a.withdraw(amt)<<endl;
}
else if(ch==3){
cout << "Enter amount to deposite :";
cin >>amt;
a.deposit(amt);
}
}while(ch!=4);
return 0;
}
No comments:
Post a Comment