Search This Blog

Thursday, 20 August 2020

Atm balance enquiry

 #include<iostream>

using namespace std;

class ATM

{

private:

int code;

int bal;

public:

long cardNo;

void setData()

{

code=1212;

bal=25000;

cardNo=12345;

}

int checkCode(int);

void showBal();

void withdraw(int);

};

int ATM::checkCode(int c)

{

if(code==c)

{

return 1;

}

else

{

return 0;

}

}

void ATM :: showBal()

{

cout<<"Current Balance is:"<<ends<<bal;

}

void ATM :: withdraw(int amt)

{

if(bal>=amt)

{

bal=bal-amt;

cout<<"withdrad successful current balance is:"<<bal;

}

else

{

cout<<"Withdraw is failed due to insufficient balance.";

}

}

int main()

{

int userCode;

int ch,amt;

ATM a;

a.setData();

cout<<"enter your code:";

cin>>userCode;

if(a.checkCode(userCode))

{

cout<<"1.BAL.Chech"<<endl;

cout<<"2.Withdraw"<<endl;

cout<<"Enter your choice:"<<endl;

cin>>ch;

switch(ch)

{

case 1:

a.showBal();

break;

case 2:

int bal;

cout<<endl<<"Enter the amount:";

cin>>amt;

/*a.showBal();

if((bal >= amt)

cout<<"you have insufficent balance:\n plese try again valid amount/nthank you for use.";

else

bal=bal-amt;

cout<<"your current balnace is :"<<bal<<endl<<"you are withdraw amount is :"<<amt;

cout<<"thank for using the fast and furies service of SBI .."<<"\SBI give you wishesh for divali HAPPY DIVALI.";

*/

break;

default:

cout<<"Invalid Choice:";

}

}

else

{

cout<<"Incorrect code plase try again:";

}

return 0;

}


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts