Skip to content

Instantly share code, notes, and snippets.

@somratcste
Last active May 21, 2018 06:49
Show Gist options
  • Save somratcste/7567485 to your computer and use it in GitHub Desktop.
Save somratcste/7567485 to your computer and use it in GitHub Desktop.
This represent an bank account system
#include<iostream>
using namespace std;
class bank
{
char name_depo[20];
int ac,ac_no;
char type_ac[20];
int balance_ac;
int n,balance;
char Y,N;
public:
void initial_value();
int deposit();
void widraw ();
void display();
};
void bank::initial_value()
{
cout<<"Please enter your account name:";
cin>>name_depo;
cout<< "Enter account no:";
cin>>ac_no;
cout<< "Enter the type:";
cin>>type_ac;
}
int bank::deposit()
{
cout<<"Enter the deposit amount:";
balance=0;
cin>>ac;
balance=ac+balance;
}
void bank:: widraw ()
{
cout<<"Your balance is:"<<ac<<'\n';
while(1){
cout<<"do you want to withdraw:(y/n)";
cin>>Y;
if(Y=='y'){
cout<<"enter the amount of withdrawl:"<<'\n';
cin>>n;
balance=balance-n;
if(balance>=0){
continue;}
else if(balance<0){
cout<<"your balance is insufficient";
cout<<'\n';
break;}
}
else if(Y=='n')
break;
}
}
void bank::display()
{
cout<<'\n';
cout<<"Your account name is :"<< name_depo<<'\n';
cout<<"Your account no :"<< ac_no<<'\n';
cout<<"Your account balance is :"<< balance;
cout<<'\n';
}
int main()
{
bank ob;
char x;
while (1){
cout<<'\n';
ob.initial_value();
ob.deposit();
ob.widraw();
ob.display();
cout<<'\n';
cout<<'\n'<<"Do you want to do another transection?(y/n):";
cin>>x;
if(x=='y')
continue;
else if (x=='n'){
cout<<'\n';
cout<<"Thank you";
cout<<'\n';
cout<<'\n';
break;
}
}
return 0;
}
@somratcste
Copy link
Author

thank you vaiya :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment