Friday, January 9, 2015

Basic Banking Program in C

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
class account
{
protected:
char *name;
int ac_no;
float balance;
char *toa;
float cy,cm,y,m,t,ci,r;
public:
void getdata()
{
name=new char[20];
cout<<"enter costumer name";
cin>>name;
cout<<"enter the a/c no.";
cin>>ac_no;
toa=new char[10];
cout<<"enter the type of a/c";
cin>>toa;
cout<<"enter the a/c open month";
cin>>cm;
cout<<"enter the a/c open year";
cin>>cy;
cout<<"enter the initial account balance";
cin>>balance;
}
void display()
{
cout<<"BALANCE:-"<<balance<<endl;
}
};
class sav_ac:public account
{
private:float deposit;
 float withdrawl;
public: void sdeposit()
{
cout<<"enter deposit money";
cin>>deposit;
balance=balance+deposit;
cout<<"DEPOSIT:-"<<deposit<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
void swithdrawl()
{
cout<<"enter withdrwal money";
cin>>withdrawl;
if((balance-withdrawl)>=1000)
{
balance=balance-withdrawl;
cout<<"WITHDRAWL:-"<<withdrawl<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
else
{
cout<<"INSUFFICIENT BALANCE\n";
}
}
void cd(float p, float q)
{
y=q-cy;
cy=q;
if((p-cm)>=0)
{
m=p-cm;
cm=p;
}
else
{
y=y-1;
m=p-cm+12;
cm=p;
}
}
void interest()
{
cout<<"Enter current interest rate";
cin>>r;
t=((y*12)+m);
ci=(balance*(pow((1.0+(r/1200.0)),t)))-balance;
balance=balance+ci;
cout<<"INTEREST:-"<<ci<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
};
class cur_ac:public account
{
private:
float deposit;
float withdrawl;
int q,t;
float p;
public:
void cdeposit()
{
cout<<"enter deposit money";
cin>>deposit;
balance=balance+deposit;
cout<<"DEPOSIT:-"<<deposit<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
void cwithdrawl()
{
cout<<"enter the withdrawl money";
cin>>withdrawl;
cout<<"Enter 1. for cash\n2. for cheque\n";
cin>>t;
if((balance-withdrawl)<1500)
{
cout<<"YOUR ACCOUNT BALANCE IS BELOW 1500/-\n";
cout<<"AFTER THIS WITHDRAWL\n";
cout<<"YOU SHOULD BE PENALTY\n";
cout<<"PRESS 0 FOR BREAK OPERATION AND 1 FOR CONTINUE";
cin>>q;
}
else
{
q=1;
}
if(q==1)
{
if(t==1)
{
if((balance-withdrawl)>=1500)
{
balance=balance-withdrawl;
cout<<"WITHDRAWL:-"<<withdrawl<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
else if((balance-withdrawl)>=0)
{
balance=balance-withdrawl;
cout<<"WITHDRAWL:-"<<withdrawl<<endl;
cout<<"BALANCE:-"<<balance<<endl;
p=(1500.0-balance)*5.0/100.0;
balance=balance-p;
cout<<"PENALTY:-"<<p<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
else
{
cout<<"YOU NOT PERMITTED TO WITHDRAWL\nDUE TO NEGATIVE BALANCE\n";
}
}

else if(t==2)
{
if((balance-withdrawl)>=1500)
{
balance=balance-withdrawl;
cout<<"WITHDRAWL:-"<<withdrawl<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
else if((balance-withdrawl)>=0)
{
balance=balance-withdrawl;
cout<<"WITHDRAWL:-"<<withdrawl<<endl;
cout<<"BALANCE:-"<<balance<<endl;
p=(1500.0-balance)*5.0/100.0;
balance=balance-p;
cout<<"PENALTY:-"<<p<<endl;
cout<<"BALANCE:-"<<balance<<endl;
}
else
{
cout<<"YOU NOT PERMITTED TO WITHDRAWL\nDUE TO NEGATIVE BALANCE\n";
}
}
}
}
};
void main()
{
clrscr();
sav_ac *a,*b;
cur_ac *c,*d;
int p=0,q,sn,i=0,j=0;
float x,y;
cout<<"enter current month & year";
cin>>x>>y;
while(p<3)
{
q=0;
if(p==1)
{
while(q!=5)
{
if(q==1)
{
if(i>0)
{
a=new sav_ac;
i++;
}
else
{
a=new sav_ac;
b=a;
i++;
}
a->getdata();
a++;
}
else if(q==2)
{
cout<<"enter your a/c s. no.";
cin>>sn;
sn=sn-1;
b=b+sn;
b->cd(x,y);
b->interest();
b->sdeposit();
b=b-sn;
}
else if(q==3)
{
cout<<"enter your a/c s. no.";
cin>>sn;
sn=sn-1;
b=b+sn;
b->cd(x,y);
b->interest();
b->swithdrawl();
b=b-sn;
}
else if(q==4)
{
cout<<"enter your a/c s. no.";
cin>>sn;
sn=sn-1;
b=b+sn;
b->cd(x,y);
b->interest();
b->display();
b=b-sn;
}
cout<<"Enter choice\n1. for new account\n2. for deposit\n3. for withdrawkl\n4. for display balance\n5. for exit current account\n";
cin>>q;
}
}
else if(p==2)
{
while(q!=5)
{
if(q==1)
{
if(j>0)
{
c=new cur_ac;
j++;
}
else
{
c=new cur_ac;
d=c;
j++;
}
c->getdata();
c++;
}
else if(q==2)
{
cout<<"enter your a/c s. no.";
cin>>sn;
sn=sn-1;
d=d+sn;
d->cdeposit();
d=d-sn;
}
else if(q==3)
{
cout<<"enter your a/c s. no.";
cin>>sn;
sn=sn-1;
d=d+sn;
d->cwithdrawl();
d=d-sn;
}
else if(q==4)
{
cout<<"enter your a/c s. no.";
cin>>sn;
sn=sn-1;
d=d+sn;
d->display();
d=d-sn;
}
cout<<"Enter choice\n1. for new account\n2. for deposit\n3. for withdrawal \n4. for display balance\n5. for exit current account\n";
cin>>q;
}
}
cout<<"enter choice\n1. for saving account\n2. for current account\n3. for exit";
cin>>p;
}
}






for more codes you can visit http://codesofprogramming.blogspot.in/

No comments:

Post a Comment