void negException :: error_Msg() const
{
cout<<"Negative Marks Not Allowed";
}
void moreException :: error_Msg() const
{
cout<<"Marks Greater than 100 Not Allowed";
}
void student :: get()
{
cin>>rollno>>name;
for(int i=0;i < 5;i++)
cin>>marks[i];
}
void student :: find_Grade()
{
if(avg >=90)
grade='S';
else if(avg >=80)
grade='A';
else if(avg >=70)
grade='B';
else if(avg >=60)
grade='C';
else if(avg >=50)
grade='D';
else if(avg >=40)
grade='E';
else
grade='F';
}
void student :: print()
{
cout<
}
void student :: calc_Avg()
{
avg=0;
try
{
for(int i=0;i < 5;i++)
{
if(marks[i] < 0)
{
negException n;
throw n;
}
else if(marks[i] > 100)
{
moreException m;
throw m;
}
else
avg+=marks[i];
}
avg/=5;
find_Grade();
print();
}
catch(negException& n)
{
n.error_Msg();
}
catch(moreException& m)
{
m.error_Msg();
}
}
int main()
{
student s;
s.get();
s.calc_Avg();
return(0);
}
0 Comments