C++ for banking transaction demo
//lastbenchers.org
#include <iostream>
using namespace std;
class transaction //declaration of class
{
int amount=10000; //private data member
public: //starting public function
void usercheck()
{
int user, password; // declaration of user id and password
cout<<"enter your user id \n";
cin>>user;
cout<<"enter your password \n";
cin>>password;
if(user==123456 && password==1234) // checking login details
{
//int user, password;
int choice;
cout<<"you have logged in successfully \n";
abc:
cout<<"enter 1 for balance enquiry 2 for deposit 3 for widthdraw \n";
cin>>choice;
switch (choice) //checking choice using switch case
{
case 1:
{
balanceinfo();
break;
}
case 2:
{
deposit();
break;
}
case 3:
{
wid();
break;
}
default:
cout<<"please! enter a right choice "<<endl; //if choice does'nt match
}
char oh;
cout<< "want to do another transaction press y \n"; //asking for another transaction
cin>>oh;
if(oh=='y' || oh=='Y')
// return usercheck();
goto abc;
}
else
{
cout<<"login details may be wrong try again \n";
char oh;
cout<< "Do you want to login again?, press y \n";
cin>>oh;
if(oh=='y' || oh=='Y') //allow to login again
return usercheck();
}
}
void balanceinfo() // balance enq function
{
cout<<"your available balance is $ "<<amount<<endl;
}
void deposit() //deposit function
{
int in;
cout<<"enter an amount \n";
cin>>in;
amount=amount+in;
cout<<"you have deposited "<<in<<" and now your balance is "<<amount;
}
void wid() //balance withdrawal function
{
int in;
cout<<"enter an amount \n";
cin>>in;
if(in<=amount)
{
amount=amount-in;
cout<<"you have taken "<<in<<" and now your balance is $"<<amount<<endl;
}
else
{
cout<<"you have less balance \n"<<endl;
// cout<<" you have only $"<<amount<<" in your balance "endl;
}
}
};
int main()
{
transaction u;
u.usercheck(); //calling class
return 0;
}
#include <iostream>
using namespace std;
class transaction //declaration of class
{
int amount=10000; //private data member
public: //starting public function
void usercheck()
{
int user, password; // declaration of user id and password
cout<<"enter your user id \n";
cin>>user;
cout<<"enter your password \n";
cin>>password;
if(user==123456 && password==1234) // checking login details
{
//int user, password;
int choice;
cout<<"you have logged in successfully \n";
abc:
cout<<"enter 1 for balance enquiry 2 for deposit 3 for widthdraw \n";
cin>>choice;
switch (choice) //checking choice using switch case
{
case 1:
{
balanceinfo();
break;
}
case 2:
{
deposit();
break;
}
case 3:
{
wid();
break;
}
default:
cout<<"please! enter a right choice "<<endl; //if choice does'nt match
}
char oh;
cout<< "want to do another transaction press y \n"; //asking for another transaction
cin>>oh;
if(oh=='y' || oh=='Y')
// return usercheck();
goto abc;
}
else
{
cout<<"login details may be wrong try again \n";
char oh;
cout<< "Do you want to login again?, press y \n";
cin>>oh;
if(oh=='y' || oh=='Y') //allow to login again
return usercheck();
}
}
void balanceinfo() // balance enq function
{
cout<<"your available balance is $ "<<amount<<endl;
}
void deposit() //deposit function
{
int in;
cout<<"enter an amount \n";
cin>>in;
amount=amount+in;
cout<<"you have deposited "<<in<<" and now your balance is "<<amount;
}
void wid() //balance withdrawal function
{
int in;
cout<<"enter an amount \n";
cin>>in;
if(in<=amount)
{
amount=amount-in;
cout<<"you have taken "<<in<<" and now your balance is $"<<amount<<endl;
}
else
{
cout<<"you have less balance \n"<<endl;
// cout<<" you have only $"<<amount<<" in your balance "endl;
}
}
};
int main()
{
transaction u;
u.usercheck(); //calling class
return 0;
}
Comments
Post a Comment