include <iostream.h>
#include <stdlib.h>
class course
{
public:
void course_inf();
void student_inf();
void result();
private:
int i,n,c,x,kr,credi[20],mark1[100][20],mark2[100][20];
char code[20][20],name[100][20];
int tot1[20],totcredit;
float avg[20],avg1[20],tot[20],endavg[100];
float tavg[100];
};
void course::course_inf()
{
cout<<"Enter the number of student: ";
cin>>n;
cout<<"Enter the number of lecture: ";
cin>>x;
cout<<endl;
cout<<"Name of the lecture name"<<endl;
cout<<"------------------------"<<endl;
for(i=1;i<=x;i++)
{
cout<<i<<".lecture : "; cin>>code[i];
cout<<i<<".lecture credi : "; cin>>credi[i];
}
cout<<endl;
}
void course::student_inf()
{
cout<<"Enter the list of student and lectures mark"<<endl;
cout<<"-------------------------------------------"<<endl;
cout<<endl;
for(i=1;i<=n;i++)
{
cout<<"Name of student: "; cin>>name[i];
cout<<endl;
for(c=1;c<=x;c++)
{
cout<<code[c]<<" "<<"midterm exam: "; cin>>mark1[i][c];
cout<<code[c]<<" "<<"final exam : "; cin>>mark2[i][c];
}
cout<<endl;
}
}
void course::result()
{
int fquit=false;
int choose;
while(!fquit)
{
cout<<" --------------------------------------------------------------- "<<endl;
cout<<" - MENU -"<<endl;
cout<<" --------------------------------------------------------------- "<<endl;
cout<<" - [1] Enter the information of courses & students - "<<endl;
cout<<" - [2] Average of each lectures - "<<endl;
cout<<" - [3] Name of student from each lecture pass and not -"<<endl;
cout<<" - [4] Average of each student - "<<endl;
cout<<" - [5] For new enter value - "<<endl;
cout<<" - [6] Exit -" <<endl;
cout<<" ----------------------------------------------------------------"<<endl;
cout<<" Choose one of them: ";
cin>>choose;
switch(choose)
{
case 1:
course::course_inf();
course::student_inf();
break;
case 2:
for(c=1;c<=x;c++)
{
tot1[c]=0; avg1[c]=0;
tot[c]=0;
}
for(c=1;c<=x;c++)
{
for(i=1;i<=n;i++)
{
tot1[c]=mark1[i][c]+mark2[i][c];
avg1[c]=tot1[c]/2;
tot[c]+=avg1[c];
}
}
for(c=1;c<=x;c++)
{
avg[c]=tot[c]/n;
}
for(c=1;c<=x;c++)
{
cout<<"Average of "<<code[c]<<": "<<avg[c]<<endl;
}
break;
case 3:
for(c=1;c<=x;c++)
{
for(i=1;i<=n;i++)
{
tot1[c]=mark1[i][c]+mark2[i][c];
avg[c]=tot1[c]/2;
if(avg[c]<50)
cout<<name[i]<<" didn't pass from "<<code[c]<<" FF"<<endl;
else if(avg[c]>=50 && avg[c]<=59)
cout<<name[i]<<" didn't pass from "<<code[c]<<" FD"<<endl;
else if(avg[c]>=60 && avg[c]<=64)
cout<<name[i]<<" passed from "<<code[c]<<" DD"<<endl;
else if(avg[c]>=65 && avg[c]<=69)
cout<<name[i]<<" passed from "<<code[c]<<" DC"<<endl;
else if(avg[c]>=70 && avg[c]<=74)
cout<<name[i]<<" passed from "<<code[c]<<" CC"<<endl;
else if(avg[c]>=75 && avg[c]<=79)
cout<<name[i]<<" passed from "<<code[c]<<" CB"<<endl;
else if(avg[c]>=80 && avg[c]<=84)
cout<<name[i]<<" passed from "<<code[c]<<" BB"<<endl;
else if(avg[c]>=85 && avg[c]<=89)
cout<<name[i]<<" passed from "<<code[c]<<" BA"<<endl;
else if(avg[c]>=90)
cout<<name[i]<<" passed from "<<code[c]<<" AA"<<endl;
}
}
break;
case 4:
totcredit=0;
for(i=1;i<=n;i++)
{
tavg[i]=0; endavg[i]=0;
}
for(i=1;i<=n;i++)
{
for(c=1;c<=x;c++)
{
tot1[c]=mark1[i][c]+mark2[i][c];
avg[c]=tot1[c]/2;
tavg[i]+=((avg[c])*credi[c]);
}
}
for(c=1;c<=x;c++)
{
totcredit+=credi[c];
}
for(i=1;i<=n;i++)
{
endavg[i]=tavg[i]/(totcredit);
cout<<name[i]<<"'s average is: "<<endavg[i]<<endl
}
break;
case 5:
course::course_inf();
course::student_inf();
course::result();
break;
case 6:
fquit=true;
break;
default: cout<<"- !!! WRONG CHOICE !!! -"<<endl;
}
}
}
void main()
{
course student;
student.result();
}