#include <iostream>
using namespace std;
class Student{
public:
    double attn;
    int n;
    double *grades;
    double CGPA;
    
    Student(){
        attn=0;
        n=0;
        grades=nullptr;
    }
    Student(double attn, int n, double* grades){
        this->attn=attn;
        this->n=n;
        this->grades=new double[n];
        for(int i=0;i<n;i++){
            this->grades[i]=grades[i];
        }
    }
    ~Student(){
        delete[] grades;
    }
    double calculateGradeSumOfCourses(){
        double sum=0;
        for(int i=0;i<n;i++){
            sum+=grades[i];
        }
        return sum;
    }
    void calculateCGPA(){
        if(n==0) {
            CGPA=0;
            return;
        }
        double sum=calculateGradeSumOfCourses();
        CGPA=sum/n;
    }
};


class L4Student : public Student{
public:
    double thesis;
    
    L4Student(){
        thesis=0;
    }

    L4Student(double attn, int n, double* grades, double thesis): Student(attn, n, grades){
        this->thesis=thesis;
    }
    void calculateCGPA(){
        if(n==0) {
            CGPA=0;
            return;
        }
        double sum=calculateGradeSumOfCourses();
        sum+=thesis;
        CGPA=sum/(n+1);
    } 
};


int main(){
    double gradesOfS[]={4.00, 3.75, 3.75, 3.5, 4.00};
    Student s(1, 5, gradesOfS);
    
    s.calculateCGPA();
    cout<<s.CGPA<<endl;
    
    double gradesOfL4S[]={4.00, 3.75, 3.5, 3.5, 2.50};
    L4Student l4s(0.75, 5, gradesOfL4S, 4.00);
    
    l4s.calculateCGPA();
    cout<<l4s.CGPA<<endl;
    return 0;
}
