Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <cstring>
- #include <string>
- #include "personaz.h"
- #include "studentez.h"
- #include "data.h"
- using namespace std;
- int tot = 0;
- void riempi_vettore (int, Studente *);
- void inserisci_voto (Studente *, int);
- int main()
- {
- int scelta = -1, n;
- Studente *p;
- cout << " PROGRAMMA PER LA GESTIONE DEGLI STUDENTI ISCRITTI AL ";
- cout << "\n I ANNO DEL CdL DI ING.INFORMATICA 270\n ";
- cout << "\nQuanti studenti desideri registrare? ";
- cin >> n;
- tot = tot + n;
- try {
- p = new Studente[n];
- if (p == NULL) {
- throw p; }
- }
- catch (Studente *punt) {
- cout << "\nMemoria insufficiente! ";
- exit (EXIT_FAILURE);
- }
- while (scelta != 0) {
- cout << "\n ##########################\n ";
- cout << " MENU : \n";
- cout << " 1. Inserisci studenti\n " << " 2. Inserisci voti\n ";
- cout << " 3. \n " << " 4. Modifica voto\n ";
- cout << " 5. Calcola media\n " << " 6. Fine\n";
- cout << " ########################## ";
- cout << "\n\n Inserisci scelta: ";
- cin >> scelta;
- system ("CLS");
- switch (scelta) {
- case 1:
- riempi_vettore(n, p);
- break;
- case 2:
- inserisci_voto(p,n);
- break;
- }
- }
- delete [] p;
- return 0;
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- void riempi_vettore (int N, Studente *p)
- {
- int i, serial, day, month, year, controllo;
- char stringa[15];
- char *name, *surname, *address;
- for (i=0; i<N; i++) {
- cout << "\ninserisci numero di matricola dello studente " << i+1 << " : ";
- cin >> serial;
- p->Setmatricola(serial);
- fflush(stdin);
- /* cout << p->Getmatricola(); */
- cout << "\nInserisci il nome dello studente: ";
- cin.getline (stringa,15);
- p->Setnome(name);
- /* cout << p->Getnome(); */
- cout << "\nInserisci il cognome dello studente: ";
- cin.getline (stringa,15);
- p->Setcognome(stringa);
- do {
- controllo = 0; //se uguale a 0 tutto ok, se uguale a -1 cacca
- cout << "\ninserisci giorno di nascita: ";
- cin >> day;
- cout << "\ninserisci mese di nascita: ";
- cin >> month;
- cout << "\ninserisci anno di nascita: ";
- cin >> year;
- fflush(stdin);
- Data scemo(&controllo,day,month,year);
- p->nascita = &scemo;
- }
- while(controllo == -1);
- /* cout << p->Getanno(); */
- cout << "\ninserisci indirizzo: Via ";
- cin.getline(stringa,15);
- p->Setvia(stringa);
- p->Setmatrice();
- p++;
- }
- }
- void inserisci_voto (Studente *p, int tot)
- {
- int i;
- cout << "Gli studenti iscritti sino ad ora sono " << tot << "\n";
- for (i=0; i<tot; i++) {
- cout << i+1 << ". ";
- cout << p->Getnome << " " << p->Getcognome << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement