#include "student.cpp"
int main() {
Student *alin = new Student("Alin", "Bata", "1870513350037", 2008, 6, 3, 5, 8, 4, 9);
alin->studentPrint();
ofstream store ("studenti.txt");
if (store.is_open()) {
store << alin->getNume() << alin->getPrenume() << alin->getMediaGenerala() <<
alin->getCrediteObtinute() << endl;
}
else cout << "Unable to open file" << endl;
store.close();
return 0;
}
student.cpp file
#include <iostream>
#include <fstream>
#include "student.h"
using namespace std;
//constructors
Student::Student() {
this->nume = "";
this->prenume = "";
this->cnp = "";
this->promotia = 0;
this->grupa = 0;
this->notaAnalizaMatematica = 0;
this->notaProgramareC = 0;
this->notaAlgoritmica = 0;
this->notaBazeleInformaticii = 0;
this->notaEngleza = 0;
this->mediaGenerala = 0;
this->crediteObtinute = 0;
};
int calculcredite(double notaAnalizaMatematica, double notaProgramareC, double notaAlgoritmica,
double notaBazeleInformaticii, double notaEngleza);
Student::Student(string nume, string prenume, string cnp, int promotia, int grupa,
double notaAnalizaMatematica, double notaProgramareC, double notaAlgoritmica,
double notaBazeleInformaticii, double notaEngleza) {
this->nume = nume;
this->prenume = prenume;
this->cnp = cnp;
this->promotia = promotia;
this->grupa = grupa;
this->notaAnalizaMatematica = notaAnalizaMatematica;
this->notaProgramareC = notaProgramareC;
this->notaAlgoritmica = notaAlgoritmica;
this->notaBazeleInformaticii = notaBazeleInformaticii;
this->notaEngleza = notaEngleza;
this->mediaGenerala = ((notaAnalizaMatematica + notaProgramareC
+ notaAlgoritmica + notaBazeleInformaticii + notaEngleza) / 5);
this->crediteObtinute = calculcredite(notaAnalizaMatematica,
notaProgramareC, notaAlgoritmica, notaBazeleInformaticii, notaEngleza);
};
int calculcredite(double notaAnalizaMatematica, double notaProgramareC,
double notaAlgoritmica, double notaBazeleInformaticii, double notaEngleza) {
int temp = 0;
if(notaAnalizaMatematica >= 5) {
temp = temp + 6;
}
if(notaProgramareC >= 5) {
temp = temp + 6;
}
if(notaAlgoritmica >= 5) {
temp = temp + 6;
}
if(notaBazeleInformaticii >= 5) {
temp = temp + 6;
}
if(notaEngleza >= 5) {
temp = temp + 6;
}
return temp;
};
//deconstructors
//get functions
double Student::getMediaGenerala(void) {
return this->mediaGenerala;
};
int Student::getCrediteObtinute(void) {
return this->crediteObtinute;
};
string Student::getNume(void) {
return this->nume;
};
string Student::getPrenume(void) {
return this->prenume;
};
//print class
void Student::studentPrint(void) {
cout << this->nume << this->prenume << this->cnp << this->promotia << this->grupa <<
this->notaAnalizaMatematica << this->notaProgramareC << this->notaProgramareC <<
this->notaAlgoritmica << this->notaBazeleInformaticii << this->notaEngleza <<
this->mediaGenerala << this->crediteObtinute << endl;
};
student.h file //here is the class declared
#include <string>
using namespace std;
class Student {
public:
Student();
Student(string nume, string prenume, string cnp, int promotia, int grupa, double notaAnalizaMatematica,
double notaProgramareC, double notaAlgoritmica, double notaBazeleInformaticii, double notaEngleza);
~Student();
//get functions
string getNume(void);
string getPrenume(void);
double getMediaGenerala(void);
int getCrediteObtinute(void);
//print function
void studentPrint(void);
private:
string nume;
string prenume;
string cnp;
int promotia;
int grupa;
double notaAnalizaMatematica;
double notaProgramareC;
double notaAlgoritmica;
double notaBazeleInformaticii;
double notaEngleza;
double mediaGenerala;
int crediteObtinute;
};
ty








