You are on page 1of 9

ENSEM Deprt MATHS & INFO

CORRIGE C++/POO a.affiche(); a.deplace(3,2); a.affiche(); getch(); b=a; b.deplace(5,4); b.affiche(); getch(); } Exercice II-1

Le 05/04/2012 1ire GI

Srie de TD n1 C++/POO
Exercice I /* fichier header file t_date.h */ #include<iostream.h> class t_date { private : int j; int m; int a; public: void init_date(int, int, int); void affiche_date(void); }; /* fichier source c++ date.cpp */ #include<iostream.h> #include<conio.h> #include"t_date.h" void t_date ::init_date(int jour, int mois, int an) { j=jour; m=mois; a=an; } void t_date::affiche_date(void) { cout<<" la date entree est : "<<j<<" / "<<m<<" / "<<a;} int main(void) { t_date dat; dat.init_date(20,2,2012); dat.affiche_date(); getch(); } Exercice II #include<iostream.h> #include<conio.h> class pointt { int x, y ; public : void initialise(int ,int); void deplace(int, int); void affiche(); }; void pointt::initialise(int abs, int ord) { x=abs; y= ord;} void pointt::deplace(int dx, int dy) { x += dx ; y+= dy ;} void pointt::affiche(void) { cout<<"je suis en ( "<<x<<" , "<<y<<" )" ; cout<<endl; } int main(void) { pointt a, b; a.initialise(1,4);

/* fichier header pointt.h */ #include<iostream.h> #include<conio.h> class pointt { int x, y ; public : void initialise(int ,int); void deplace(int, int); void affiche(); }; void pointt::initialise(int abs, int ord) { x=abs; y= ord;} void pointt::deplace(int dx, int dy) { x += dx ; y+= dy ;} void pointt::affiche(void) { cout<<"je suis en ( "<<x<<" , "<<y<<" )" ; cout<<endl; } /* pointt1.cpp */ #include<conio.h> #include"pointt.h" void test(void) {pointt u; u.initialise(1,4); u.affiche(); u.deplace(3,2); u.affiche(); } int main(void) { test(); getch(); }

Exercice II-2 /* fichier header pointt.h */ #include<iostream.h> #include<conio.h> class pointt { int x, y ; public : void initialise(int ,int); void deplace(int, int); void affiche(); };

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO

CORRIGE C++/POO int main(void) { pointt v; v=test(); v.deplace(3,2); v.affiche(); getch(); } Exercice II-4 /* heather file modifie pointt.h */

Le 05/04/2012 1ire GI

void pointt::initialise(int abs, int ord) { x=abs; y= ord;} void pointt::deplace(int dx, int dy) { x += dx ; y+= dy ;} void pointt::affiche(void) { gotoxy(x,y); cout<<"je suis en ( "<<x<<" , "<<y<<" )"<<endl; } /* pointt2.cpp */ #include<iostream.h> #include<conio.h> #include"pointt.h" void test(pointt &u) {u.initialise(1,4); u.affiche(); u.deplace(3,2); u.affiche(); } int main(void) { pointt a; test(a); getch(); } Exercice II-3 /* fichier header pointt.h */ #include<iostream.h> #include<conio.h> class pointt { int x, y ; public : void initialise(int ,int); void deplace(int, int); void affiche(); }; void pointt::initialise(int abs, int ord) { x=abs; y= ord;} void pointt::deplace(int dx, int dy) { x += dx ; y+= dy ;} void pointt::affiche(void) { cout<<"je suis en ( "<<x<<" , "<<y<<" )" ; cout<<endl; } /* pointt3.cpp */ #include<conio.h> #include"pointt.h" pointt test(void) { pointt u; u.initialise(1,4); u.affiche(); return(u); }

#include<iostream.h> #include<conio.h> class pointt { int x, y ; public : pointt(); pointt(int ,int); ~pointt(); void deplace(int, int); void affiche(); }; pointt::pointt(void) { x=1 ; y= 1; } pointt::pointt(int abs, int ord) { x=abs; y= ord;} pointt::~pointt() { cout<<" votre programme est termine !! a bientot ";} void pointt::deplace(int dx, int dy) { x += dx ; y+= dy ;} void pointt::affiche(void) { cout<<"je suis en ( "<<x<<" , "<<y<<" )" ; cout<<endl; } /* pointt4.cpp */ #include<iostream.h> #include<conio.h> #include"pointt.h" int main(void) { pointt a(1,4); pointt b; a.affiche(); a.deplace(3,2); a.affiche(); getch(); b=a; b.deplace(5,4); b.affiche(); getch(); }

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO Exercice III

CORRIGE C++/POO

Le 05/04/2012 1ire GI else { if(m==2) { if(k==1) // annee bissextile { if(j==29) {t.j=1; t.m=m+1; t.an=an;} else {t.j=j+1; t.m=m; t.an=an;} } else if(j==28) //non bissextile {t.j=1; t.m=m+1; t.an=an;} else {t.j=j+1; t.m=m; t.an=an;} } } }} return(t);

Exercice IV #include<iostream.h> #include<conio.h> #include<stdio.h> class date { private: int j; int m; int an; public : date(){j=1 ; m=1 ; an= 2011 ;} date(int, int, int) ; date(int jj, int mm) {j=jj ; m=mm ; an=0 ;} date(int z) { j=z ; m=3 ; an=2011 ;} void saisie() { cout<<endl<<endl<<"entrez la date jj mm aa : " ; cin>>j>>m>>an; } int bissextile(); date lendemain(); void affiche(){ cout<<"\n\n\t"<<j<<" / "<<m<<" / "<<an; } //destructeur montrant l ordre de destruction des objets ~date(){ cout<<"\n\tdestruction de l objet"; affiche(); getch(); } }; int k; date::date(int jj, int mm, int aa) { j=jj; m= mm; an= aa ;} int date::bissextile() { if(((an%4==0) && (an%100!=0))||(an%400==0)) return(1); else return(-1); } date date::lendemain() { date t; if(m==3 || m==5 || m==7 || m==8 || m==10) { if ( j==31) { t.j=1; t.m=m+1;t.an=an;} else {t.j = j+1; t.m=m; t.an=an;} } else { if( m==4 || m==6 || m==9 || m==11) { if(j==30) { t.j=1; t.m= m+1 ; t.an=an;} else {t.j= j+1 ;t.m=m; t.an=an;} } else {if(m==12) { if(j==31) { t.j=1; t.m=1; t.an=an+1;} else {t.j=j+1; t.m=m; t.an=an;} }

} void main() { date d; date x(15) ; date y(6, 7, 2010) ; char choix; do{ d.affiche() ; x.affiche() ; y.affiche() ; d.saisie(); k=d.bissextile(); if( k==1) cout<<" \ncette annee est bissextile\n"; else cout<<" \ncette annee est non bissextile\n"; x=d.lendemain(); cout<<" \n\nla date aujourdhui est : \n\n"; d.affiche(); cout<<"\n la date du lendemain est :\n\n "; x.affiche(); cout<<endl<<endl<<"\n\nvoulez vous saisir une autre date O/N : "; fflush(stdin); cin>>choix ; }while(choix=='O'); getch(); }

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO

CORRIGE C++/POO

Le 05/04/2012 1ire GI

Srie de TD n2 C++/POO
Exercice 1 #include<conio.h> #include<iostream> //#include"t_rationnel.h" using namespace std; class t_rationnel { int num; int den; public: t_rationnel(); t_rationnel(int, int); t_rationnel operator +(t_rationnel &); t_rationnel operator *(t_rationnel &); t_rationnel operator -(t_rationnel &); t_rationnel operator /(t_rationnel &); friend void affiche(t_rationnel &); friend bool operator ==(t_rationnel & , t_rationnel &); friend bool operator <=(t_rationnel & , t_rationnel &); }; t_rationnel ::t_rationnel() { num=0; den =1; } t_rationnel ::t_rationnel(int x, int y) { num=x; den =y; } t_rationnel t_rationnel ::operator +(t_rationnel &r) { t_rationnel s; s.num = num*r.den + den*r.num ; s.den= den*r.den; return s; } t_rationnel t_rationnel ::operator *(t_rationnel &r) { t_rationnel p; p.num = r.num*num ; p.den= r.den*den; return p; } t_rationnel t_rationnel ::operator -(t_rationnel &r) { t_rationnel m; m.num = num*r.den - den*r.num ; m.den= r.den*den; return m; } t_rationnel t_rationnel ::operator /(t_rationnel &r) { t_rationnel d; d.num = num*r.den ; d.den= den*r.num; return(d); } void affiche(t_rationnel &r) { cout<<r.num<<"/"<<r.den<<endl; } bool operator <=(t_rationnel &x,t_rationnel &y )

{if((x.num<=y.num) &&(x.den>y.den)) return true; else return false; } bool operator ==(t_rationnel &x,t_rationnel &y ) {if((x.num==y.num) &&(x.den==y.den)) return true; else return false; } int main(void) { t_rationnel r(6,7); t_rationnel t( 1,3); t_rationnel res; cout<<"les rationnels sont :\n\n"; affiche(r); affiche(t); getch(); cout<<"leur somme est :"<<endl<<endl; res=r+t; affiche(res); getch(); cout<<"leur produit est :"<<endl<<endl; res=r*t; affiche(res); getch(); cout<<"leur difference est :"<<endl<<endl; res=r - t; affiche(res); getch(); cout<<"leur rapport est :"<<endl<<endl; res= r/t; affiche(res); if(r==t) cout<<"\n\nles deux rationnels sont egaux."; else { if(r<=t) { cout<<"le rationnel "; affiche(r); cout<<" est plus petit que "; affiche(t); } else { cout<<"le rationnel "; affiche(t); cout<<" est plus petit que "; affiche(r); }}getch(); return 0; } Exercice 2 #include<iostream> #include<conio.h> #include<string.h> using namespace std; int n; class appartement {int nbre_app ; struct appart { char nom_proprio[15] ; float superfie; int num_etage; int nb_chambre; struct adress { char rue[25]; int num; char ville[20]; } adr;

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO

CORRIGE C++/POO

Le 05/04/2012 1ire GI

}tab_app[10]; public: appartement(int); void saisie_appart(); int recherche_appart(char *); friend void affich_appart(appartement &); }; appartement::appartement(int n) {nbre_app=n;} void appartement::saisie_appart(void) { int i; cout<<"\n\n\n\n remplissage des appartements de cet objet : \n\n"; for(i=0;i<nbre_app;i++) {cout<<endl<<endl<<" Pour appartement "<<i+1; cout<<"\n\tnom du proprietaire : "; cin>>tab_app[i].nom_proprio; cout<<"\n\tsuperficie : "; cin>>tab_app[i].superfie; cout<<"\n\tnumero etage : "; cin>>tab_app[i].num_etage; cout<<"\n\tnombre de chambres : "; cin>>tab_app[i].nb_chambre; cout<<"\n\tadresse :rue , num, ville : "; cin>>tab_app[i].adr.rue>>tab_app[i].adr.num>>tab _app[i].adr.ville; cout<<endl<<endl; } } int appartement::recherche_appart(char *x) {int i, a=-1; for(i=0; i<nbre_app; i++) if((strcmp(tab_app[i].adr.ville, x)==0) && (tab_app[i].superfie>=150)) { cout<<"\n\tnom du proprietaire : "<<tab_app[i].nom_proprio; cout<<"\n\tsuperficie : "<<tab_app[i].superfie; a=1;} return(a); } void affich_appart(appartement &x) { for(int i=0; i<n; i++) {cout<<endl<<endl<<" Pour appart "<<i+1; cout<<"\n\tProprietaire : "; cout<<x.tab_app[i].nom_proprio; cout<<"\n\tsuperficie : "; cout<<x.tab_app[i].superfie; cout<<"\n\tnumero etage : "; cout<<x.tab_app[i].num_etage; cout<<"\n\tnombre de chambres : "; cout<<x.tab_app[i].nb_chambre; cout<<"\n\tadresse :rue , num, ville : "; cout<<x.tab_app[i].adr.rue<<" "<<x.tab_app[i].adr.num<<" "<<x.tab_app[i].adr.ville; cout<<endl<<endl;}}

int main() { char v[20]; int x=0; cout<<"Veuillez donnez le nbre des appartement pour cet objet : "; cin>>n; appartement b(n); b.saisie_appart(); do{ cout<<"entrez une ville : "; cin>>v; cout<<"\n\nRecherche des Appartements de + de 150 m2 a : "<<v; if(b.recherche_appart(v)== -1) { cout<<"\n\naucun appartement ne repond a ces conditions."; x=-1;} }while(x!=0); cout<<"\n\n\nAffichage de tous les appartements\n\n"; affich_appart(b); getch(); return 0; }

Srie de TD n3 C++/POO
Exemple dapplication : classe Epouse #include<iostream.h> #include<conio.h> #include<string.h>

class personne { protected: char nom[40]; char prenom[40]; public : personne(char *n, char *p) { strcpy(nom, n); strcpy(prenom, p); cout<<"personne : \n\n" ; } ~personne() { cout<<" destruction de l objet " ; cout<<personne ..... "<<endl; } char *donne_nom(void) { return nom; } char *donne_prenom(void) { return prenom; } }; class epouse : public personne { protected : char nom_de_jeune_fille[40]; public : epouse(char *a, char *b, char *n) : personne(a,b)

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO

CORRIGE C++/POO

Le 05/04/2012 1ire GI

{ strcpy(nom_de_jeune_fille , n); cout<<" Nom de jeune fille est : " ; cout<<endl<<endl; } ~epouse() { cout<<" destruction de l objet " ; cout<<epouse ..... "<<endl; } void affiche(void) { cout<<" Nee " ; cout<<nom_jeune_fille<<endl; } };

{ protected : float ca; float frais; float plafond; float sal_final; public : representant(int n, char *nm, char *pm, char *f, float s, float c, float fr); ~representant(){cout<<endl<<"****destruction d objet representant****"<<endl;getch();} void afficher(); void cal_sa_final(); }; salarie ::salarie(int n,char *nm,char *pm,char *f, float s) { numero=n; nom= new char[strlen(nm)]; strcpy(nom,nm); prenom= new char[strlen(pm)]; strcpy(prenom,pm); fonction= new char[strlen(f)]; strcpy(fonction,f); salaire=s; } void salarie :: afficher() { clrscr(); cout<<" le salarie est : "<<endl<<endl; cout<<endl<<endl<<"Numero : "<<numero; cout<<endl<<endl<<"Nom et Prenom : "<<nom<<" "<<prenom; cout<<endl<<endl; cout<<"Fonction : "<<fonction; cout<<endl<<endl<<"Salaire fixe : "<<salaire; getch(); } representant ::representant(int n, char *nm, char *pm, char *f, float s, float c, float fr) : salarie( n,nm,pm,f,s) { ca =c; frais =fr; } void representant :: cal_sa_final() { int catg=0; com=0.0; clrscr(); cout<<"Choix de categorie pour : "<<nom<<" "<<prenom; cout<<endl<<endl<<endl; cout<<" 1 - 1000\n 2 - 1500\n 3 - 2000 \n 4 - 2500 \n 5 - 3000\n\n"; cout<<"donnez la categorie de plafond : "; cin>>catg; if(ca<100000 ) com= ca*0.02; else { if(ca<200000) com=2000 + (ca - 100000)*0.04; else com=6000 + (ca - 200000)*0.06; }

void main(void) { personne p("khaddour", "fatima") ; // construit un objet de type personne cout<<" Madame : "<<p.donne_nom()<<" "<<p.donne_prenom()<<endl<<endl; cout<<"-----------------------------"<<endl<<endl; //construit un objet de type epouse // dynamiquement epouse *e=new epouse("benali", "latefa", " toto"); cout<<"------------------------------"<<endl<<endl; cout<<e->donne_nom(); //appel de fc membre heritee cout<<" "<<e->donne_prenom(); //appel de fc membre heritee e->affiche(); cout<<"------------------------------"<<endl<<endl; delete e; getch(); }
Principe dhritage appliqu la gestion salariale

#include<iostream.h> #include<conio.h> #include<string.h> float com, fremb; class salarie { protected: int numero; char *nom; char *prenom; char *fonction; float salaire; public : salarie(int,char *,char *,char *, float); ~salarie(){ cout<<endl<<"====destruction d objet salarie===="<<endl;getch(); } void afficher(); }; class representant : public salarie

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO switch(catg) { case 1 : plafond=1000; break; case 2 : plafond=1500; break; case 3 : plafond=2000; break; case 4 : plafond=2500; break; case 5 : plafond=3000; break; } if (frais > plafond) fremb= plafond; else fremb = frais; sal_final =salaire + com + fremb ;

CORRIGE C++/POO

Le 05/04/2012 1ire GI

float vecteur3d:: normax(vecteur3d &g,vecteur3d &p ) { float n1, n2 ; float res1 ; n1= sqrt(g.x*g.x + g.y*g.y + g.z*g.z); n2= sqrt(p.x*p.x + p.y*p.y + p.z*p.z); res1=(n1 >= n2)? 1 :0 ; if(res1==1) {g.affiche(); return(n1);} else { p.affiche(); return(n2);} } int coincide(vecteur3d &v1, vecteur3d &v2) { if((v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z)) return(1); else return(0); } void main(void) { vecteur3d g(2,5,9); vecteur3d k; vecteur3d *m=new vecteur3d(6,1, 0); float q; q= k.normax(g, *m); cout<<endl<<endl<<" la norme la plus grande " cout<<" est : "<<q; int s; s= coincide(g, *m); if(s==1) cout<<endl<<endl<<" les deux vecteurs coincident..."; else cout<<endl<<endl<<" les deux vecteurs ne coincident pas..."; getch(); }

} void representant :: afficher() { salarie :: afficher(); cout<<endl<<endl; cout<<"Commission : "<<com; cout<<endl<<endl<<"Remboursement des notes de frais : "<<fremb; cout<<endl<<endl<<"Total a payer : "<<sal_final; } void main(void) { salarie s(1,"toto", "tata","secretaire",8798.50); salarie *p; p=new salarie(2,"ouz","fat","employe", 5670.25); representant x(3,"xxxxx", "yyyyy", "representant", 7500, 186000,750); s.afficher(); p->afficher(); x.cal_sa_final(); x.afficher(); getch();}

Corrig du TP4_C++
Exercice 2 #include<iostream.h> #include<conio.h> #include<math.h> class vecteur3d { float x; float y; float z; public: vecteur3d (float a, float b, float c) { x=a; y=b; z=c; } vecteur3d(){ x=0; y=0; z=0; } void affiche() { cout<<" les coordonnees du vecteur " cout<<" sont : "<<endl; cout<<" x= "<<x; cout<<" y= "<<y; cout<<" z= "<<z<<endl<<endl; } float normax(vecteur3d &, vecteur3d &); friend int coincide(vecteur3d &, vecteur3d &); };

Exercice 3-1 #include<iostream> #include<conio.h> #include<string.h> #include<stdlib.h> using namespace std; typedef struct { int j; int m; int a;}date; int i; int n; class comp_b { protected: char num_compt[8]; char nom[20]; date dat_nais ; float solde ; public: comp_b(){ strcpy(num_compt, "1AA"); strcpy(nom, "toto"); solde =0; } comp_b(char *, char *,int, int, int, float);

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO

CORRIGE C++/POO

Le 05/04/2012 1ire GI

~comp_b(); void saisie() {cout<<" \n\n num compte-----> "; cin>>num_compt ; cout<<" \n\nNom----> "; cin>>nom ; cout<<" \n\nDate naissance-----> "; cin>>dat_nais.j>>dat_nais.m>>dat_nais.a; cout<<" \n\nSolde-----> "; cin>>solde; cout<<endl;} void depot(float); void retrait(float); void affiche(void); void transfert(comp_b &,float); friend bool recherche(comp_b &); }; comp_b::comp_b(char *num, char *name,int jj, int mm, int aa, float som) { num = new char[8]; name = new char[20]; strcpy(num_compt, num); strcpy(nom, name); dat_nais.j=jj; dat_nais.m= mm; dat_nais.a=aa; solde = som;} comp_b::~comp_b(){} void comp_b::depot( float f){ solde += f;} void comp_b::retrait( float f){ solde -= f;} void comp_b::affiche(void) { cout<<" compte num = "; cout <<num_compt<<endl<<endl; cout<<" Nom----> "<<nom<<endl; cout<<" Date naissance-----> " ; cout <<dat_nais.j<<" / "<<dat_nais.m<<" / " ; cout<<dat_nais.a<<endl; cout<<" Solde-----> "<<solde<<endl; } void comp_b::transfert(comp_b &v ,float f) { solde -=f; v.solde += f ; affiche(); v.affiche(); } bool recherche(comp_b &z) { if(z.solde <0) { cout<<" le compte debiteur est : \n\n"; z.affiche(); return true; } else return(false); } int main() { int n,i, k,j, choix; char num[8], name[20]; date d; float montant , f2 ;

comp_b *p; cout<<" donner la taille du tableau n: "; cout<<endl<<endl; cin>>n ; p= new comp_b[n]; for(i=0; i<n; i++) { cout<<"\n\n saisir les donnes du "<<i<<"\n\n"; p[i].saisie(); cout<<" \n\nQue voulez vous faire pour cet elt "<<i<<":\n\n"; cout<<"\t\t1- retrait ou \n\t\t2- depot \n\t\t sinon taper 0? "; cin>>choix; if(choix ==1) { cout<<" \ndonnez le montant a retirer : "; cin>>f2; p[i].retrait(f2);} else if(choix==2) {cout<<" \nDonnez le montant a verser : "; cin>>f2; p[i].depot(f2); } } for(i=0; i<n; i++) p[i].affiche(); cout<<"\n\n donner les indices des 2 elts pour faire le transfert : "; cin>>i>>j ; cout<<"\n\ndonner le montant a transferer : "; cin>>montant; p[i].transfert(p[j], montant); for(i=0; i<n; i++) if(recherche( p[i])) break; getch(); return 0; } Exercice 3-2 #include<iostream.h> #include<conio.h> #include<string.h> #include<stdlib.h> typedef struct { int j; int m; int a;}date; int i; int n; class comp_b { protected: char num_compt[8]; char nom[20]; date dat_nais ; float solde ; public: comp_b(){ strcpy(num_compt, "1AA"); strcpy(nom, "toto"); solde =0; } comp_b(char *, char *,int, int, int, float); ~comp_b();

Mme OUAZZANI F.Z

ENSEM Deprt MATHS & INFO

CORRIGE C++/POO

Le 05/04/2012 1ire GI

void depot(float); void retrait(float); void affiche(void); void transfert(comp_b &,float); friend int recherche(comp_b &); }; class jeune: public comp_b { float reserve; public: jeune(char *, char *,int, int, int, float,float =0); void cumulreserve(float x) { reserve += x;} void affiche() { comp_b::affiche(); cout<<"\n\n la reserve cumulee est : " ; cout<<reserve; } }; comp_b::comp_b(char *num, char *name,int jj, int mm, int aa, float som) { num = new char[8]; name = new char[20]; strcpy(num_compt, num); strcpy(nom, name); dat_nais.j=jj; dat_nais.m= mm; dat_nais.a=aa; solde = som;} comp_b::~comp_b(){} void comp_b::depot( float f){ solde += f;} void comp_b::retrait( float f){ solde -= f;} void comp_b::affiche(void) { cout<<" compte num = " cout <<num_compt<<endl<<endl; cout<<" Nom----> "<<nom<<endl; cout<<" Date naissance-----> " ; cout<<dat_nais.j<<" / "<<dat_nais.m<<" / " ; cout <<dat_nais.a<<endl; cout<<" Solde-----> "<<solde<<endl; } void comp_b::transfert(comp_b &v ,float f) {solde -=f; v.solde += f ; affiche(); v.affiche();} int recherche(comp_b &z) { int x=(z.solde<0)? 1:0; if(x==1) {cout<<" le compte debiteur est : \n\n"; z.affiche(); } return(x); } jeune::jeune(char *num, char *name,int jj, int mm, int aa, float som, float r) : comp_b(num, name, jj, mm, aa, som) { reserve = r;} void main() { int choix=0, k;

char num[8], name[20]; date d; float s , f2 ; cout<<" Voulez vous ouvrir : \n 1- Un compte normal ou \n 2 - Un compte jeune ?"; cout<<endl<<endl; cin>>k ; switch(k) { case 1 : { cout<<"\n\n num compte----> "; cin>>num ; cout<<" \n\nNom----> "; cin>>name ; cout<<" \n\nDate naissance-----> "; cin>>d.j>>d.m>>d.a; cout<<" \n\nSolde-----> "; cin>>s; cout<<endl; comp_b C(num, name, d.j, d.m, d.a,s); cout<<" \n\nQue voulez vous faire :\n\n"; cout<<"\t\t1- retrait ou \n\t\t2depot \n\t\t sinon taper 0? "; cin>>choix; if(choix ==1) { cout<<" \n\nDonnez le montant a retirer : "; cin>>f2; C.retrait(f2); } else if(choix==2) { cout<<" \n\nDonnez le montant a verser : "; cin>>f2; C.depot(f2); } C.affiche(); } case 2 : {cout<<"\n\n num compte----> "; cin>>num ; cout<<"\n\nNom----> ";cin>>name ; cout<<" \n\nDate naissance-----> "; cin>>d.j>>d.m>>d.a; cout<<" \n\nSolde-----> "; cin>>s; cout<<endl; jeune Y(num, name, d.j, d.m, d.a,s); cout<<" \n\nQue voulez vous faire :\n\n"; cout<<"\t\t1- retrait ou \n\t\t2depot \n\t\t sinon taper 0? "; cin>>choix; if(choix ==1) { cout<<" \n\nDonnez le montant a retirer : "; cin>>f2; Y.retrait(f2); } else if(choix==2) { cout<<" \n\nDonnez le montant a verser : "; cin>>f2; Y.depot(f2*0.9); Y.cumulreserve(f2*0.1); } clrscr(); Y.affiche(); } } }

Mme OUAZZANI F.Z

You might also like