cout<<"***WELCOME TO ATM MAYBANK!!***"<< endl;
cout<<"Please Enter Your Account Number: ";
cin>>accnum;
bool x;
do{
cout << "\nPlease Enter Your PIN Number: ";
cin >> pin;
if (pin==12345){
cout << "PIN correct!" << endl;
pintrials = -1;
x = true;
}
else{
pintrials--;
cout << "You have "<< pintrials<< " attempts remaining."<<endl;
x = false;
}
if (pintrials == 0){
cout<<"\nYou have exceed the PIN attempts."<<endl;
cout<<"Please contact us in any branch of our bank."<<endl;
cout<<"Thank you."<<endl;
break;
}
}while (x != true);
option(accnum,balance);
system("pause");
}
void checkbal(string accnum, int balance){
cout<<"Account number:"<<accnum<<endl;
cout<<"Your balance is RM"<<balance<<endl;
}
void withdraw(string accnum, int balance){
int withdraw=0,wdamount=0;
char sel,ans;
cout<<"Please choose your transaction."<<endl;
cout<<"1.)RM100"<<endl;
cout<<"2.)RM300"<<endl;
cout<<"3.)RM500"<<endl;
cout<<"4.)Enter value."<<endl;
cin>>sel;
do{
switch(withdraw){
case 1:wdamount=100; //<-----Why I cannot choose any of this?
cout<<"Withdraw RM100."<<endl;break;
case 2:wdamount=300;
cout<<"Withdraw RM300."<<endl;break;
case 3:wdamount=500;
cout<<"Withdraw RM500."<<endl;break;
case 4:cout<<"Enter withdraw value:RM";
cin>>wdamount;break;
default:cout<<"Invalid Input."<<endl;break;
}
if(withdraw==1 || withdraw==2 || withdraw==3 || withdraw==4)
break;
else
cout<<"Do you want to continue? [Y/y-Yes N/n-No]"<<endl;
cin>>ans;
}while(ans=='Y' && ans=='y');
balance=balance-wdamount;
cout<<"Your balance is RM"<<balance<<endl;
}
void deposit(string accnum, int balance){
int deposit;
cout<<"Please enter your cash into space provided."<<endl;
cout<<"Please enter amount that you put in :";
cin>>deposit;
balance=balance+deposit;
cout<<"Your balance now is RM"<<balance<<endl;
}
void option(string accnum, int balance){
int choice;
char ans;
do{
cout<<"Please choose your :"<<endl;
cout<<"1.)Check Balance."<<endl;
cout<<"2.)Cash Withdraw."<<endl;
cout<<"3.)Cash Deposit."<<endl;
cin>>choice;
switch(choice){
case 1:checkbal(accnum, balance);break;
case 2:withdraw(accnum, balance);break;
case 3:deposit(accnum,balance);break;
default:cout<<"Invalid Input."<<endl;
}
cout<<"Do you want to continue? [Y/y-Yes N/n-No]";
cin>>ans;
}while(ans=='Y' || ans=='y');
}
I cannot choose the withdraw amount in switch loop, anyone teach me how to solve?