Université de Ndjamena
Faculté de sciences exactes et appliquées.
Département : informatique.
Niveau : L2
UE: programmation C++.
Objet : Travail pratique.
Groupe N°:
Chef du groupe : 1- Vincent Ferrier Ramadingue
Membres : 2- Ndjerane Aguillard
3-Roumba Bertrand
4-Idriss Amrassou
5-Dingamnayel Poradoum Blanchard
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Etudiant {
private:
string nom;
string prenom;
int matricule;
string date_naissance;
string filiere;
string niveau;
string matiere;
double notesControle;
double notesExamen;
int jour,mois,annee;
public:
Etudiant(string nom, string prenom, int matricule, string filiere,
string niveau, string matiere, double notesControle, double
notesExamen,int jour,int mois,int annee) {
this->nom = nom;
this->prenom = prenom;
this->matricule = matricule;
this->filiere = filiere;
this->niveau = niveau;
this->matiere = matiere;
this->notesControle = notesControle;
this->notesExamen = notesExamen;
this->jour = jour;
this->mois = mois;
this->annee = annee;
}
void afficherInformations() {
cout << "Nom: " << nom << endl;
cout << "Prenom: " << prenom << endl;
cout << "Matricule: " << matricule << endl;
cout<<"Date de naissance : ";
cout << jour<< mois << annee<< endl;
cout << "Filiere: " << filiere << endl;
cout << "Niveau: " << niveau << endl;
cout << "Matiere: " << matiere << endl;
cout << "Notes de controle: " << notesControle << endl;
cout << "Notes d'examen: " << notesExamen << endl;
}
};
int main(){
vector<Etudiant> listeEtudiants;
int conteur=0;
int choix;
do {
cout << "1. Inserer un étudiant" << endl;
cout << "2. Supprimer un étudiant" <<endl;
cout << "3. Modifier les informations d'un étudiant" << endl;
cout << "4. Afficher les informations d'un' étudiants " << endl;
cout << "5. Quitter ! " << endl;
cout << "Choix : ";
cin >> choix;
switch (choix) {
case 1: {
string nom, prenom, date_naissanc, filiere, niveau,
matiere;
int matricule;
double notesControle, notesExamen;
int jour;
int mois;
int annee;
cout << "Nom : ";
cin >> nom;
cout << "Prénom : ";
cin >> prenom;
cout << "Matricule : ";
cin >> matricule;
cout << "Jour : ";
cin >> jour;
cout << "Mois : ";
cin >> mois;
cout << "Annee : ";
cin >> annee;
cout << "Filière : ";
cin >> filiere;
cout << "Niveau : ";
cin >> niveau;
cout << "Matière : ";
cin >> matiere;
cout << "Notes de contrôle : ";
cin >> notesControle;
cout << "Notes d'examen : ";
cin >> notesExamen;
Etudiant nouvelEtudiant(nom, prenom, matricule, filiere,
niveau, matiere, notesControle, notesExamen,jour,mois,annee);
listeEtudiants.push_back(nouvelEtudiant);
cout << "Etudiant ajouté avec succès." << endl;
break;
}
case 2: {
int index;
cout << "Indice de l'étudiant à supprimer : ";
cin >> index;
if (index >= 0 && index < [Link]()) {
[Link]([Link]() + index);
cout << "Etudiant supprimé avec succès." << endl;
} else {
cout << "Indice invalide." << endl;
}
break;
}
case 3: {
int index;
cout << " Indice de l'étudiant à modifier : ";
cin >> index;
if (index >= 0 && index < [Link]()) {
Etudiant& etudiant = listeEtudiants[index];
string nom, prenom, date_naissance, filiere, niveau,
matiere;
int matricule;
double notesControle, notesExamen;
int jour, mois, annee;
cout << "Nouveau nom : ";
cin >> nom;
cout << "Nouveau prénom : ";
cin >> prenom;
cout << "Nouveau matricule : ";
cin >> matricule;
cout << "Nouvelle date de naissance : "<<endl;;
cout << "Jour : ";
cin >> jour;
cout << "Mois : ";
cin >> mois;
cout << "Annee : ";
cin >> annee;
cout << "Nouvelle filière : ";
cin >> filiere;
cout << "Nouveau niveau : ";
cin >> niveau;
cout << "Nouvelle matière : ";
cin >> matiere;
cout << "Nouvelles notes de contrôle : ";
cin >> notesControle;
cout << "Nouvelles notes d'examen : ";
cin >> notesExamen;
etudiant = Etudiant(nom, prenom, matricule, filiere,
niveau, matiere, notesControle,notesExamen,jour,mois,annee);
cout << "Informations de l'étudiant modifiées avec
succès." << endl;
} else {
cout << "Indice invalide." << endl;
}
break;
}
case 4:
if ([Link]() == 0) {
cout << "Aucun étudiant enregistré." << endl;
} else {
cout << "Liste des étudiants : " << endl;
for (int i = 1; i < [Link](); i++) {
listeEtudiants[i].afficherInformations();
cout << endl;
}
}
break;
case 5:
cout << "Au revoir !" << endl;
break;
default:
cout << "Choix invalide." << endl;
}
} while (choix != 5);
return 0;
}