#include <iostream>
#define N 5
#define K 3
using namespace std;
class course {   
private:
	int code;
	int ECTS;
	double b1;
	double cf1;
	double b2;
	double cf2;
public:
	//default constructor
	course(){
	code=0; ECTS=0; b1=0.0;b2=0.0;cf1=0.0;cf2=0.0;};
	// constructor with parameter list
	course(int in_code, int in_ECTS, double in_b1,
		double in_cf1, double in_b2, double in_cf2)
	{
		code=in_code;
		ECTS=in_ECTS;
		b1=in_b1;
		cf1=in_cf1;
		b2=in_b2;
		cf2=in_cf2;
	};

	double get_b1() {return b1;};
	double get_b2() {return b2;};
	double get_cf1() {return cf1;};
	double get_cf2() {return cf2;};


	double course_grade(){
		double tb;
			tb=get_b1()*get_cf1()/100.0+get_b2()*get_cf2()/100.0;
		return tb;	
	};

	//double get_course_grade() { return course_grade();};

	void output(){
	cout<<code<<endl; 
	cout<<ECTS<<" "<<b1<<"  "<<cf1<<"  "<<b2<<" "<<cf2<<endl;
		};
	int get_ECTS() { return ECTS;}

}; // end class course

class student{
private:
	int am;
	course lessons[N];
public:
	// default constructor
	student() {
		cout<<"KLHSH DEFAULT CONSTRUCTOR"<<endl;
	am=0;
	for (int j=0;j<N;j++)
	lessons[j]=course();
	};
	// CONSTRUCTOR WITH PARAMETER LIST
	student( int in_am, course in_lessons[N])
	{am =in_am;
	for (int j=0;j<N;j++)
	lessons[j]=in_lessons[j];};

	int total_ECTS(){
	int total=0,i;

	for (i=0;i<N;i++)
	{ if ( lessons[i].course_grade()>=5.0 )
			total =total + lessons[i].get_ECTS();
	return total;
	};
	}  // end total_ECTS
void output_student()
{cout<<"AR.MHTRWOU ="<<am<<endl;
  for (int k=0;k<N;k++)
	  lessons[k].output();
}

 double get_lesson_course_grade(int i)
 { return lessons[i].course_grade();}





	double running_average() 
	{double total=0.0; int i,count=0;

	for (i=0;i<N;i++)
	{	if ( lessons[i].course_grade()>=5.0 )
		{
			total =total + lessons[i].course_grade();
			count++;
		}
	};
	if (count>0) return total/count; else return 0;
	
	}; //end da
	
	void print_total_ECTS() 
		{cout<<"total ECTS="<<total_ECTS()<<endl;};
	
	void print_running_average() 
	{cout<<"running average = "<<running_average()<<endl;};
	}; // end class student

void main()
{ int m=0,in_code, in_ECTS, i, j;
double in_b1, in_cf1, in_b2, in_cf2, sum=0.0;

int sum_total_ECTS=0;

course in_lessons[N];
int in_am;
int test[9000];
student f[K];

// initialization array test
for (i=0;i<9000;i++) test[i]=0;

for (i=0;i<K;i++) {
// data entry using random numbers
	do 
	in_am=rand()%9000+1000;
	// test for double am
	while (test[in_am-1000]==1);
	test[in_am-1000]=1;

	for (j=0;j<N;j++)
	{
	in_code=rand()%900+100;
	in_ECTS=rand()%5+2;
	in_b1=(rand()%11)*1.0;
	in_cf1=(rand()%100)*1.0;
	in_b2=(rand()%11)*1.0;
	in_cf2=100.0-in_cf1;
	// RHTH KLHSH STON CONSTRUCTOR course WITH PARAMETER LIST!!!!
	in_lessons[j]=course(in_code,in_ECTS,in_b1,in_cf1,in_b2,in_cf2);
	}; // end for j - lessons
// RHTH KLHSH STON CONSTRUCTOR student WITH PARAMETER LIST!!!!
f[i]=student(in_am,in_lessons);
f[i].output_student();
} // end for i - students

for (i=0;i<K;i++)
{
	f[i].print_total_ECTS();
	f[i].print_running_average();

		sum_total_ECTS+=f[i].total_ECTS();
		cout<<sum_total_ECTS<<endl;

	for (j=0;j<N;j++)
		if (f[i].get_lesson_course_grade(j)>=5.0)
		{m++; sum+=f[i].get_lesson_course_grade(j);}



} // end for i
if (m>0) cout<<"mesos OROS FOITHTWN ="<<sum/m<<endl;

}   // end main
