Vous êtes sur la page 1sur 12

#include<iostream.h> #include<stdio.h> #include<conio.h> #include<string.h> #include<alloc.

h> int compt=0; class personne { protected: char *nom; char *prenom; char *email; public: personne(char *, char *, char *); personne() { nom=new char[strlen("hoho")]; prenom=new char[strlen("hoho")]; email=new char[strlen("hoho")]; strcpy(nom,"hoho"); strcpy(prenom,"hoho"); strcpy(email,"hoho");} void lire(); void modifiernom(); void modifierprenom(); void modifiermail(); void afficher(); };

class etudiant : public personne { int promo; float notes[4]; float moy; public : etudiant(); etudiant(char *, char *, char *, int, float *); void saisie(void); int cal_moy(void); void afficher(); };

class employe : public personne { protected : float salaire; public : employe(char *, char *, char *, float ); employe(); void saisie(); void afficher(); };

class enseignant : public employe { private : char *matiere; char *dept; int nbre_h;

int cat; public: enseignant(char *, char *, char *, float, char *, char *, int, int ); enseignant(); void saisie(); void cal_indem(); void afficher(); };

class administratif : public employe { private : int an_rec; public: administratif(char *, char *, char *, float, int ); administratif(); void saisie(); int cal_anc(); void afficher(); }; personne::personne(char *a, char *b, char *c) { nom = new char[strlen(a)]; prenom = new char[strlen(b)]; email = new char[strlen(c)]; strcpy(nom, a); strcpy(prenom, b); strcpy(email, c); }

void personne::lire(void) { cout<<endl<<endl<<"entrer le nom , prenom et email : "; personne y; cin>>y.nom; cin>>y.prenom; cin>>y.email ; nom=new char[strlen(y.nom)]; strcpy(nom, y.nom); prenom=new char[strlen(y.prenom)]; strcpy(prenom, y.prenom); email=new char[strlen(y.email)]; strcpy(email, y.email);

cout<<endl<<endl; }

void personne::modifiernom(void) { cout<<" donner le nouveau nom :"; cin>>nom; cout<<endl; } void personne::modifierprenom(void) { cout<<" donner le nouveau prenom :"; cin>>prenom; cout<<endl; } void personne::modifiermail(void)

{ cout<<" donner le nouveau nom :"; cin>>email; cout<<endl; } void personne::afficher(void) { //clrscr(); cout<<"Nom ....: "<<nom<<endl<<endl; cout<<"Prenom ....: "<<prenom<<endl<<endl; cout<<"Email ....: "<<email<<endl<<endl; //getch(); }

etudiant:: etudiant(char *a, char *b, char *c, int p, float *t) :personne(a,b,c) { promo = p; for(int i=0; i<4;i++) *(notes+i) = *(t+i); } etudiant :: etudiant() : personne() { int j; for(j=0; j<4; j++) notes[j]=0. ; } void etudiant::saisie(void) { personne::lire(); cout<<endl<<endl<<" promo..."; cin>>promo;

cout<<"saisir 4 notes : "; for(int j=0;j<4;j++) { cout<<endl<<"notes["<<j<<"]= "; scanf("%f",notes+j);} }

void etudiant::afficher(void) { personne::afficher(); cout<<" Promo...."<<promo<<endl; for(int j=0; j<4;j++) cout<<endl<<"notes["<<j<<"]= "<<(*(notes +j)); cout<<endl<<" moy = "<<moy; getch(); } int etudiant::cal_moy(void) { int j; float s=0; for(j=0; j<4; j++) s += notes[j]; moy = s/4; if(moy>=12) return(1); else if( moy>= 8 && moy<12) return(0); else return(-1);

employe::employe(char *a, char *b, char *c,float s) :personne(a,b,c) { salaire = s;} employe::employe() :personne() { salaire =0; } void employe::afficher() { personne::afficher(); cout<<endl<<" salaire : "<<salaire; } void employe::saisie(void) { personne::lire(); cout<<endl<<endl<<" salaire..."; cin>>salaire; } enseignant::enseignant(char *a, char *b, char *c,float s, char *m, char *d, int h, int ca) :employe(a,b,c,s) { matiere = new char[strlen(m)]; strcpy(matiere, m); dept = new char[strlen(d)]; strcpy(dept, d); nbre_h =h; cat = ca; }

void enseignant::saisie(void) { employe::saisie(); enseignant y; cout<<endl<<endl<<" matiere..."; cin>>y.matiere; cout<<endl<<endl<<" departement..."; cin>>y.dept; matiere=new char[strlen(y.matiere)]; strcpy(matiere, y.matiere); dept=new char[strlen(y.dept)]; strcpy(dept, y.dept); cout<<endl<<endl<<" nbre_heures sup : "; cin>>nbre_h; cout<<endl<<endl<<" categorie : "; cin>>cat; } enseignant::enseignant() :employe() { matiere=new char[strlen("xxxx")]; dept=new char[strlen("xxxx")]; strcpy(matiere,"xxxx"); strcpy(dept,"xxxx"); nbre_h=0; cat =0; } void enseignant::afficher() { personne::afficher();

cout<<endl<<" matiere enseignee : "<<matiere; cout<<endl<<" departement : "<<dept; cout<<endl; } void enseignant::cal_indem() { int x; switch(cat) { case 1 : { x=nbre_h - 280; if(nbre_h >= 280) salaire += x*220; } break; case 2 : { x=nbre_h - 320; if(nbre_h >= 320) salaire += x*180; } break; case 3 : { x=nbre_h - 380; if(nbre_h >= 380) salaire += x*150; } break; } if(x>=30) compt ++; }

administratif::administratif(char *a, char *b, char *c,float s,int r) :employe(a,b,c,s) { an_rec = r;} administratif::administratif()

:employe() { an_rec =0;} void administratif::saisie() { employe::saisie(); cout<<endl<<endl<<" annee recrutement : "; cin>>an_rec; } void administratif::afficher() { employe::afficher(); cout<<endl<<" ancienete : "<<(2011-an_rec); cout<<endl; } int administratif::cal_anc() { return(2011 - an_rec);} int main() { etudiant e[3]; enseignant g[3]; administratif f[3]; float pourc; int rat=0, ad=0; for(int i=0; i<3 ; i++) e[i].saisie(); for(int i=0; i<3 ; i++) {if((e[i].cal_moy())==1) ad++; else if((e[i].cal_moy())==0)

rat ++; else continue; } for(int i=0; i<3; i++) e[i].afficher(); cout<<endl<<endl<<" nbre candidats qui ont valide : "<<ad; cout<<endl<<endl<<" nbre candidats qui ont un rattrapage : "<<rat; getch();

cout<< "---enseignants----"<<endl; for(int i=0; i<3 ; i++) g[i].saisie(); cout<<endl<<endl; cout<<" pourcentage des enseignants ayant fait plus de 30 h sup : "; pourc = float(compt)/3; cout<<pourc<<"%"; getch();

for(int i=0; i<3 ; i++) f[i].saisie(); getch(); cout<<endl<<endl; cout<<endl<<endl<<"---liste des administratifs partant a la retraite----"; for(int i=0; i<3 ; i++) if(f[i].cal_anc()>= 25) f[i].afficher(); else

continue ; getch();

return 0;

Vous aimerez peut-être aussi