Vous êtes sur la page 1sur 9

#include<iostream.

h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<stdio.h>
#include<process.h>
#include<iomanip.h>
#include<math.h>
#include<fstream.h>
#include<stdlib.h>
void cus();
void agent();
void welcome();
void store();
void newcus();
void feedback();
void old();
void storecus();
void storegen();
char* policy();
void oldagent();
void newagent();
int p1=300;
char q1='%';
float r1=3.0;
double s1=54564646846;
struct address
{int hno;
char area[30];
char city[30];
char stat[30];
address()
{hno=0;}
address(int)
{hno=12;
strcpy(area,"mambalam");
strcpy(city,"chennai");
strcpy(stat,"tn");}
address(char)
{hno=40;
strcpy(area,"Ville parle");
strcpy(city,"Mumbai");
strcpy(stat,"Maharashtra");}
address(float)
{hno=56;
strcpy(area,"Chetpet");
strcpy(city,"Chennai");
strcpy(stat,"TN");}
address(double)
{hno=3;
strcpy(area,"Chedda Nagar");
strcpy(city,"Mumbai");
strcpy(stat,"Maharashtra");}
void display()
{cout<<"House no:";
cin>>hno;
cout<<"\n Area:";
gets(area);

cout<<"\n City:";
gets(city);
cout<<"\n State :";
gets(stat);
cout<<endl;}
};
class agn
{int age;
float sal;
char category[80];
public:agn()
{age=0;
sal=0;}
agn(int)
{code=123;
age=30;
address addagn(int p1);
sal=30000;
strcpy(category,"Zonal manager");
strcpy(name,"Venkat");
polsld=20;}
agn(char)
{code=367;
age=35;
address addagn(char q1);
sal=70000;
strcpy(category,"Director");
strcpy(name,"Sheela");
polsld=55;}
int code;
char name[80];
int polsld;
address addagn;
void accept()
{
cout<<"Code";
cin>>code;
cout<<"\n Name";
gets(name);
cout<<"\n Age:";
cin>>age;
cout<<"Policies sold:";
cin>>polsld;
addagn.accept();}
void assign()
{if(polsld>=10&&polsld<20)
{sal=10000;
strcpy(category,"Branch manager");}
else if(polsld>=20&&polsld<30)
{
sal=25000;
strcpy(category,"Zonal manager");
else if(polsld>=30&&polsld<50)
{sal=40000;
strcpy(category,"District manager");}
else if(polsld>=50)
{sal=70000;
strcpy(category,"Director");}
else{

cout<<"\n Sorry You r not recruited."<<endl;


getch();
exit(0);}
}
void display()
{cout<,"Ccode:"<<code<<endl;
cout<<"Name"<<name<<endl;
cout<<"Age:"<<age<<endl;
addagn.display();
cout<<"Salary:"<<sal<<endl;
cout<<"Category:"<<category<<endl;
cout<<"No of policies ssold:"<<polsld;}
void update()
{cout<<"Enter the no of policies";
cin>>polsld;};
class cust
{int age;
char name[80];
float polamt;
int polterm;
int sa;
int modpay;
float interest;
float premium;
address addcust;
public:
int code;
char polbt[20];
cust()
{age=0;
polamt=0;
polterm=0;
cust(int)
{age=33;
strcpy(name,"Rajesh");
strcpy(polbt,"jeevan anand");
addresss addcust(r1);
polamt=10000;
polterm=5;
modpay=1;
interest=35000;
premium=30000;
code=123;
cust(char)
{age=40;
strcpy(name,"Lakshmi");
strcpy(polbt,"Money Back");
address addcust(s1);
polamt=40000;
polterm=10;
modpay=3;
interest=40000;
premium=80000;
code=789;;}
void accept()
{cout<<"Enter Detailss"<<endl;
cout<<"Code:";
cin>>code;
cout<<"\n Name:";
gets (name);

addcust,accept();
cout<<"policy amount:";
cin>>polamt;
cout<<"\n policy term:";
cin>>polterm;
cout<<"\n Mode of payment"<<endl;
cout<<"1.Cheque 2.Debit card 3.Credit card 4.Internet banging 5.Cash";
cin>>modpay;}
void display();
void calcinterest();
void calcpremium();
};
void cust::display()
{char ans;
cout<<"code:"<<code<<endl;
cout<<"name:"<<name<<<endl;
addcust.display();
cout<<"policy:"<<polbt<<endl;
cout<<"policy amount:"<<polamt<,endl;
switch(modplay)
{
case 1:cout<<"Cheque "<<endl;
break;
case 2:cout<<,"Debit Card"<<endl;
break;
case 3:cout<<"Credit Card "<<endl;
break;
case 4:cout<<"Internet banking"<<endl;
break;
case 5:cout<<"cash"<<endl;
break;
default:cout<<"Invalid"<<"Do you want to continue?";
cin>>ans;
if(ans=='y')
newcus();
else
exit(0);
}
cout<<"policy term:"<<polterm <<endl;
cout<<"Interest:"<<interest<<endl;
cout<<<"Premium:"<<premium<,endl;}
struct poldet{
char polname[50];
char benefits[100];
float matamt;
int minage;
int maxage;
int years;
float sumassured;
char term[30];
float polamt;
void display()
{cout<<"policy name:"<<polname<<endl;
cout<<"benefits:"<<benefits<<endl;
cout<<<"maturity amount:"<<matamt<<endl;
cout<<"minimum age:"<<minage<<endl;
cout<<"maximum age:"<<maxage<<endl;
cout<<"no. of years:"<<years<<endl;cout<<"assured sum:"<<sumassured<<endl;
cout<<"term:"<<term<<endl;
cout<<"policy amount :"<<polamt<<endl;}

};
poldet endow={"endowment policy","helps in case of sudden death",5000000,18,60,6
0,200000,"half yearly",3000000};
poldet monbak={"moneyback policy ","has loan facility",2000000,30,80,20,100000,"
yearly",1000000};
poldet jeevanand={"jeevan anand policy ","for a happyy life",10000000,40,70,3000
000,"quarterly",7000000};
cust c1(1);
cust c2('*');
agn a1(1);
agn a2('*');
void cust::calcinterest()
{if(strcmpi(polbt,"endowment")==0)
interest=(5*polamt*polterm)/100;
else
interest=(7*polamt*polterm)/100;}
void cust::calcpremium()
{poldet h;
ifstream j("Policies.dat",ios::binary);
while(!j.eof())
{
j.read((char*)&h,sizeof(h));
if(strcmpi(h,polname,polbt)==0)
{if(age>(h,minage+h.maxage)/2)
sa=h.ssummassured*polterm*2/1000;
if(modpay==3)
sa*=0.7;
if(modpay==4)
sa*0.9;
premium=sa*polamt/1000;}
}
void welcome()
{int reply;
cout<<"Welcome to Life Insurance Corporation of India";
cout<<endl;
cout<<"Main Menu"<<endl;
cout<<"1.Customer"<<endl;
cout<<"2.Agent"<<endl;
cout<<"3.Feedback"<<endl;
cin>>reply;
sswitch(reply)
{case 1:cus();
break;
case 2:agent();
break;
case 3:feedback();
break;}
}void stroe()
{ofstream a("Policies.dat,"ios::binary);
if(!a)
{cout<<"Error";
getch();
exit(0);
}
a.write((char*)&endow,sizeof(endow));
a.write((char*)&monbak,sizeof(monbak));
a.write((char*)&jeevanand,sizeof(jeevanand));
a.close();}

void storecus()
{ofstream b("Customer.dat",ios::binary|ios::app);
if(!b)
cout<<"Error";
b.write((char*)&c1,sizeof(c1));
b,write((char*)&c2,sizeof(c2));
b.close();}
void storegen()
{ofstream c("Agent.dat".ios::binary|ios::app);
if(!c)
cout<<"Error";
c.write((char*)&a1,sizeof(a1));
c.write((char*)&a2,sizeof(a2));
c.close();}
void feedback()
{clrscr();
char fdback[100];
cout<<<"Enter feedback:";
gets(fdback);
cout<<endl<<"Thank you";
ofstream d("Feedback.dat",ios::binary|ios::app);
d.write((char*)&fdback,sizeof(fdback));
d.close();}
void cus()
{int reply;
char rep='y';
while(rep=='y')
{{cout<<"Enter 1.Old Customer 2.New Customer";
cin>>reply;
switch(reply);
{case 1:old();
break;
case 2:newcus();
break;
}
cout<<"Another customer?";
cin>>rep;}
void old()
{int code 1;
clrscr();
int flag=0;
char rep='y',ch,pol[30];
cust c(1);
cout<<"Enter the code"<<endl;
cin>>code1;
ifstream k("Customer.dat",ios::binary);
if(!k)
cout<<"Error";
while(!k.eof()&&flag==0)
{k.read((char*)&c,sizeof(c));
if(c,code==code1)
{flag=1;
c.display();
cout<<"Do you want to have more policies?";
cin>>rep;
while(rep=='y')
{strcpy(pol,policy());
cout<<"Confirm policy?";
cin>>ch;
if(ch=='y')

{strcat(c.polbt,pol);}
cout<<"Any more?";
cin>>rep;
c.display();}
}}
cout<<"Thanks";
k.close();}
void newcus()
{clrscr();
fstream f("Customer.dat",ios::binary|ios::in|ioss::out|ios::app);
cout<<endl;
cust c(1);
int n;
n=sizeof(c);
char pol[30],rep;
c.accept();
strcpy(pol,policy());
cout<<"Confirm?";
cin>>rep;
if(rep=='y')
strcpy(c.polbt,pol);
else
{clrscr();
policy();}
c.calcpremium();
c.calcinterest();
f.write((char)*&c,sizeof(c));
f.seekg(n,ios::cur);
f.read((char*)&c,ssizeof(c));
c.display();}
char *policy()
{poldet p;
int r;
char rep;
cout<<"the policies are"<<endl;
ifstream s("policies.dat",ios::binary);
if(!s)
cout<<"error";
cout<<"1.endowment policy 2.money back policy 3.jeevan anand "<<endl;
cin>>r;
switch(r)
{
case 1: s.read((char*)&p,sizeof(p));
p.display();
return p.polname;
break;
case 2: s.seekg(sizeof(p),ios::beg);
s.read((char*)&p,sizeof(p));
p.display();
return p.polname;
break;
case 3: s.seekg(2*size of(p),ios::beg);
s.read((char*)&p,sizeof(p));
p.display();
return p.polname;
break;
deafault:cout<<"invalid"<<"Do you want to enter again?"<<endl;
cin>>ep;

if(rep==y);
if(rep=='y')
policy();
else
exit(0);
}
s.close();
return "invalid";}
void agent()
{int y;
cout<<"1.new agent 2.old agent ";
cin>>y;
switch(y)
{case 1: newagent();
break;
case 2 : oldagent();
break;}
}
void newagent()
{clrscr();
cout<<"thank u fr choosing lic"<<<endl;
agn a(1);
a.accept(0;
a.display();
ofstream n("agent.dat",ios::binary|ios::app);
n.write((char*)&a,sizeof(a));
n.close();}
void oldagent()
{clrscr();
int cd;agn t(1);char rep;int l,f=0,n=-sizeof(t);
cout<<"enter code";
cin>>cd;
fstream o("agent.dat",ioss::binary|ios::out|ios::in|ios::app);
while(!o.eof()&&f==0)
{o.read((char*)&t,sizeof(t));
if(t.code==cd)
{f=1;
t.display();
cout<<"do you want to update your status?(y/n)";
cin>>rep
if(rep=='y')
{t.update();
o.seep(n,ios::cur);
o.write((char*)&t,sizeof(t));
o.seekg(n,ios::cur);
o.read((char*)&t,sizeof(t));
t.display();
}}}
cout<<"thank you"<<endl;
o.close();}
void main()
{clrscr();char rep='y';
do
{
store();
storecus();
storeagn();
welcome();
cout<<"do you want to continue";
cin>>rep;

}(while(rep=='y');
}

Vous aimerez peut-être aussi