#include
using namespace std;
class ATM{
string userName;
string password;
public:
string getUserName(){return userName;}
string getPassword(){return password;}
ATM(string user,string pass){
userName=user;
password=pass;
}
void login(){
string name;
string pass;
int count=1;
do{
cout<<"****** Welcome My ATM *******"<<"\n";
cout<<"Please input your name: ";
getline(cin,name);
cout<<"Input password: ";
getline(cin,pass);
count++;
if(count>3){
cout<<"you have logined only 3 times!";
exit(0);
}
system("cls");
}while(name!=getUserName()||pass!=getPassword());
cout<<"Login success!"<<"\n";
}
};
int A;int wm; //wm=money that withdraw
float bal=0;
float balance();
float menu();
float withdraw();
float deposit();
float information();
float D;//D=money that you dispost
int main(){
{
ATM us("chan","123");
us.login();
//call function login for prepare with constructor User(string user,string pass).
cin.sync();
cin.get();
}
// system("pause");
menu();
system("pause");
return 0;
}
float menu(){
do{
system("cls");
cout<<"1.check Balance"<
cin>>A;
}while(A<1>5);
switch(A){
case 1: balance();break;
case 2: withdraw();break;
case 3: deposit();break;
case 4: information();break;
case 5: exit(0);
default:
exit(0);
}
}
float balance(){
system("cls");
cout<<"Your balance is $ "<
menu();
return 0;
}
float withdraw()
{
system("cls");
do{
cout<<"\n 1. $20"<
cin>>wm; //wm=Withdraw menu;
cout<
switch(wm){
case 1:
if(bal<20 br="" cls="" system=""> cout<<"\nyour money is enough"<
cout<<"\nyour have only : $"<
}
else
{system("cls");
cout<<"\nsuccess with your withdraw :$" <<20 br="" endl=""> bal=bal-20;
cout<<"New Balance : $"<
case 2:
if(bal<60 br="" cls="" system=""> cout<<"\nyour money is enough"<
}
else
{system("cls");
cout<<"\nsuccess with your withdraw: $"<<60 br="" endl=""> bal=bal-60;
cout<<"New Balance : $"<
case 3:
if(bal<100 br=""> cout<<"\nyour money is enough"<
}
else
{system("cls");
cout<<"\nsuccess with your withdraw: $"<<100 br="" endl=""> bal=bal-100;
cout<<"New Balance : $"<
case 4:
if(bal<200 br=""> cout<<"\nyour money is enough"<
}
else
{
system("cls");cout<<"\nsuccess with your withdraw: $"<<200 br="" endl=""> bal=bal-200;
cout<<"New Balance : $"<
case 5:
cout<<"\nEXITING WITHDRAW MENU..."<
system("cls");
menu();
break;
}
system("pause");
menu();
return 0;
}
float deposit()
{
system("cls");
cout<<"Input money: $";
cin>>D;
bal=bal+D;
cout<<"Depositing $"<
menu();
return 0;
}
float information(){
system("cls");
cout<<"Welcome to my information"<
menu();
cout<
No comments:
Post a Comment