ATM Machine Program Via Classes
In This Program We Will learn How to Use GOTO statement , Case , If Else statement , and Classes
Program
#include<iostream>
using namespace std;
int balance = 3000; // global variable declaration
class create
{
protected :
int A_Number , CNIC , balance ;
char name[30];
public:
void get()
{
cout<<"Enter Your Account Number : "<<endl;
cin>>A_Number;
cout<<"Enter Your Name : "<<endl;
cin>>name;
cout<<"Enter Your CNIC : ";
cin>>CNIC;
cout<<"Enter Your Amount : "<<endl;
cin>>balance;
}
void show()
{
cout<<"Your Account Information" <<endl;
cout<<"Your Account number is = "<<A_Number <<endl;
cout<<"Your Name is : "<<name<<endl;
cout<<"Your Balance is : "<<balance<<endl;
}
};
class binquiry
{ protected :
int balance;
public:
void showib(int a)
{ balance = a;
cout<<"Your Amount Balance is : " <<balance<<endl;
}
};
class deposit
{
protected :
int D_Amount;
public:
void showda()
{
cout<<"Enter Amount to be depositd";
cin>>D_Amount;
balance = balance + D_Amount;
cout<<"Your Remaining Balance Is "<<balance<<endl;
}
};
class withdrawl
{ protected:
int withdrawl;
public:
void showwd()
{
cout<<"Enter Amount To be Withdrawal : ";
cin>>withdrawl;
balance=balance-withdrawl;
cout<<"Your Remaining Balance is : "<<balance<<endl;
}
};
int main()
{
int n;
char c;
abc :
cout<<"Select Your Choice : "<<endl;
cout<<"Enter 1 To Create a New Account : "<<endl;
cout<<"Enter 2 To View Your Balance : "<<endl;
cout<<"Enter 3 To Deposit Amount : "<<endl;
cout<<"Enter 4 To Withdrawal : "<<endl;
cout<<"Enter 5 To Exit : "<<endl;
cin>>n;
switch(n)
{
case 1:
{
create obj;
obj.get();
obj.show();
break;
}
case 2:
{
binquiry obj2;
obj2.showib(balance);
break;
}
case 3:
{
deposit obj3;
obj3.showda();
break;
}
case 4:
{
withdrawl obj4;
obj4.showwd(); // output function name show withdrawl ..
break;
}
case 5:
{
break;
}
}
cout<<"Want to perform anyother Transaction "<<endl;
cout<<"Press Y to Continue and N to Exit";
cin>>c;
if(c=='y') // character input
goto abc;
else
return 0;
}
you can also download This Software in cpp file.
Tuesday, 15 November 2016
Subscribe to:
Post Comments (Atom)
thanx bro..... keep it up :) :)
ReplyDeleteReally Thanks Bro... Insha Allah
Delete