STUDENT GRADE

Muthumari_B · September 17, 2021 · C++
#include <iostream>
using namespace std;
class student
{
    int rn,mark[10],i,t,n;
    char name[30];
    float avg;
    public:
    void getdata();
    void total();
    void average();
    void grade();
    void display();
};
void student::getdata()
{
    cout<<"Enter student name:\n";
    cin>>name;
    cout<<"Enter Roll number:\n";
    cin>>rn;
    cout<<"Enter the total number of subjects:\n";
    cin>>n;
    cout<<"Enter subject mark:\n";
    for(i=0;i<n;i++)
    {
        cin>>mark[i];
    }
}
void student::total()
{
  t=0;
  for(i=0;i<n;i++)
  {
      t=t+mark[i];
  }
      cout<<"\nTotal marks : "<<t;
}
void student::average()
{
    avg=t/n;
    cout<<"\nAverage marks : "<<avg;
}
void student::grade()
{
    if(avg>=80 && avg<=100)
    cout<<"\nGRADE A\n";
    if(avg>=50 && avg<=79)
    cout<<"\nGRADE B\n";
    else if(avg>=40 && avg<=49)
    cout<<"\nGRADE C\n";
    else
    cout<<"\nREAPPEAR\n";
}
void student::display()
{
    cout<<"\n";
    cout<<"Displaying all values\n";
    cout<<"Name : "<<name;
    cout<<"\nRoll number : "<<rn;
    for(i=0;i<n;i++)
    {
    cout<<"\nMarks : "<<mark[i];
    }
    cout<<"\nTotal : "<<t;
    cout<<"\nAverage : "<<avg;
}
int main()
{
    int cont;
    student s;
    do
    {
       s.getdata();
       s.total();
       s.average();
       s.grade();
       s.display(); 
       cout<<"\nDo you want to continue:"<<"1.yes\n"<<"2.No\n";
       cin>>cont;
    }while(cont==1);
    return 0;
}

Comments

Please sign up or log in to contribute to the discussion.