Wednesday, 5 September 2012

bank program


#include<iostream>
using namespace std;
#include<conio.h>   
class vector
{
       char name[10],type[15];
       int ac_no;
       float amt;
public:
       void ival();
       void dep();
       void withd();
       void display();
};
void vector::ival()
{
       cout<<"enter name of the account holder :";
       cin>>name;
       cout<<"\nenter account number:";
       cin>>ac_no;
       cout<<"\nenter account type :";
       cin>>type;
       cout<<"\nenter balance :";
       cin>>amt;
      
}
void vector::dep()
{
       int j;
       cout<<"\nenter the amt to be deposited :";
       cin>>j;
       amt=amt+j;
}
void vector::withd()
{
       int s;
       cout<<"\nenter the amt to b withdrawn :";
       cin>>s;
       if(s>amt)
       {
              cout<<"\nmoney cant be withdrawn";
       }
       else
       {
              cout<<"\nmoney can be withdrawn";
              amt=amt-s;
              cout<<"\nbalance amt is :"<<amt;
             
       }
}
void vector::display()
{
       cout<<"name of the account holder :";
       cout<<name;
       cout<<"\n account number:";
       cout<<ac_no;
       cout<<"\n account type :";
       cout<<type;
       cout<<"\n balance :";
       cout<<amt;
}
void main()
{
       vector v;
       int k,m;
       do
       {
       cout<<"1. enter\n"<<"2. deposit\n"<<"3. withdrawal\n"<<"4. display\n";
       cin>>k;
       switch(k)
       {
       case 1:v.ival();
              break;
       case 2:v.dep();
              break;
       case 3:v.withd();
              break;
       case 4:v.display();
              break;
       default:cout<<"function does not exist";
              break;
       }
       cout<<"\npress 1 to continue";
       cin>>m;
       }
       while(m==1);
       getch();
}

No comments:

Post a Comment