Advertisement
Guest User

gestio pro2

a guest
Mar 4th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. void redondear_e_a(Estudiant & est);
  2. /* Pre: est tiene nota */
  3. /* Post: est pasa a tener su nota original redondeada */
  4.  
  5. int main()
  6. {
  7.     Cjt_estudiants cjt;
  8.     cout << "Escriu la mida del conjunt i els elements" << endl;
  9.    
  10.     cjt.llegir_cjt_estudiants();
  11.     int opcio = 0;
  12.     while (opcio != -6) {
  13.         cout << "Escriu una opcio: " << endl;
  14.         opcio = readint();
  15.         switch (opcio) {
  16.         case -1: {
  17.             cout << "Escriu un estudiant:" << endl;
  18.             Estudiant e;
  19.             e.llegir_estudiant();
  20.             cjt.afegir_estudiant(e);
  21.             break;
  22.         }
  23.         case -2: {
  24.             int dni = readint();
  25.             if (cjt.existeix_estudiant(dni)) {
  26.                 Estudiant e = cjt.consultar_estudiant(dni);
  27.                 if (e.te_nota())
  28.                     cout << "El estudiant " << dni << " te nota " << e.consultar_nota() << endl;
  29.                 else
  30.                     cout << "El estudiant " << dni << " no te nota" << endl;
  31.             } else {
  32.                 cout << "El estudiant " << dni << " no existeix" << endl;
  33.             }
  34.             break;
  35.         }          
  36.         case -3: {
  37.             cout << "Escriu el DNI i la nova nota: ";
  38.             int dni = readint();
  39.             double nota = readdouble();
  40.             if (cjt.existeix_estudiant(dni)) {
  41.                 Estudiant e = cjt.consultar_estudiant(dni);
  42.                 if (e.te_nota())
  43.                     e.modificar_nota(nota);
  44.                 else
  45.                     e.afegir_nota(nota);
  46.                 cjt.modificar_estudiant(e);
  47.             } else {
  48.                 cout << "El estudiant " << dni << " no existeix" << endl;
  49.             }
  50.             break;
  51.         }
  52.         case -4: {
  53.             for (int i = 1; i <= cjt.mida(); ++i) {
  54.                 Estudiant e = cjt.consultar_iessim(i);
  55.                 if (e.te_nota()) {
  56.                     redondear_e_a(e);
  57.                     cjt.modificar_iessim(i, e);
  58.                 }
  59.             }
  60.             break;
  61.         }
  62.         case -5:
  63.             cjt.escriure_cjt_estudiants();
  64.             break;
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement