#include<iostream.h>
#include<conio.h>
class account
{
private :
int acno;
float balance;
public :
account() //constructor
{
acno=0; balance=0.0;
}
void init() // initializing function
{
cout<<"Enter new Account no. : "; cin>>acno;
cout<<"Enter opening balance : "; cin>>balance;
}
void display();
void deposit (float amount);
void withdraw (float amount);
~account()
{ cout<<"destructor is working";
getch();
}
};
void account :: display()
{
cout<<endl<<"Account no. : "<<acno;
cout<<endl<<"Balance : "<<balance<<endl;
}
void account :: deposit (float amount)
{
balance += amount;
return;
}
void account :: withdraw ( float amount)
{
if (amount>balance)
{
cout<<"Balance less then amount"<<endl;
cout<<"Balance : "<<balance;
}
else
{
balance -= amount;
if(balance < 500)
balance -= 25;
}
}
void main()
{
account saving[10];
int i, n;
clrscr();
cout<<"How customers : "; cin>>n;
for (i=0 ; i<=n-1 ; i++)
{
cout<<"enter details for customer no. "<<i+1<<endl;
saving[1].init();
}
int choice, cno, amount;
do{
cout<<endl<<endl<<"MAIN MENU" <<endl;
cout<<"1. Deposit :"<<endl;
cout<<"2. Withdraw :"<<endl;
cout<<"3. exit :"<<endl;
cout<<"Enter your choice (1-3) : ";
cin>>choice;
if ( (choice == 1)||(choice == 2) )
{
cout<<endl<<"Please enter the customer no. : ";
cin>>cno;
cout<<"Enter amount : ";
cin>>amount;
}
cout<<endl;
switch (choice)
{
case 1 :
saving[cno].deposit(amount);
break;
case 2 :
saving[cno].withdraw(amount);
break ;
case 3 :break;
default :
cout<<endl<<"wrong Operator" <<endl;
};
}while (choice>=1 && choice<3);
getch();
}