#include<iostream>
using namespace std;
class roll
{
protected:
char no[20];
public:
void getroll();
};
class sub
{
protected:
int s1,s2,s3,s4,total;
float avg;
public:
void getsub();
void average();
};
class student:public roll,public sub
{
public:
void display();
};
void roll::getroll()
{
cout<<"\n Enter roll number:";
cin>>no;
}
void sub::getsub()
{
cout<<"\n Enter subject marks:";
cout<<"s1:";
cin>>s1;
cout<<"s2:";
cin>>s2;
cout<<"s3:";
cin>>s3;
cout<<"s4:";
cin>>s4;
}
void sub::average()
{
total=s1+s2+s3+s4;
cout<<"TOTAL="<<total;
avg=total/4;
cout<<"\n\n AVERAGE="<<avg;
}
void student::display()
{
if(s1>=39&s2>=39&s3>=39&s4>=39)
{
if(avg>=95)
{
cout<<"\n Grade O";
}
else if(avg=90)
{
cout<<"\n Grade A";
}
else if(avg>=90)
{
cout<<"\n Grade B";
}
else if(avg>=80)
{
cout<<"\n Grade C";
}
else if(avg>=70)
{
cout<<"\n Grade D";
}
else if(avg>=60)
{
cout<<"\n Grade E";
}
else if(avg>=40)
{
cout<<"Grade F";
}
else
{
cout<<"FAIL";
}
}
}
int main()
{
int i,n;
student s[10];
cout<<"Enter the no. of students:";
cin>>n;
for(i=0;i<n;i++)
{
s[i].getroll();
}
for(i=0;i<n;i++)
{
s[i].getsub();
s[i].average();
}
for(i=0;i<n;i++)
{
s[i].display();
}
return 0;
}
OUTPUT:
BY
REGU RAM SV.
Super bro
ReplyDeletePost a Comment