Create a class to represent a Student with the following specification
Private members : rollno, name, marks of MIL, English, physics, chemistry, maths, total.
Public members :
Readdata( ) – to read initial value
Calculate( ) – to calculate total marks
Disp( ) – to display information
#include<iostream>
using namespace std;
class student
{
private:
int rollno;
char name[20];
float mil, eng, phy, chem, maths, total;
public:
void readdata( );
void calculate( );
void disp( );
};
void student::readdata( )
{
cout<<”Enter rollno:”;
cin>>rollno;
cout<<”Enter name:”;
gets(name);
cout<<”Enter marks in MIL, eng, phy, chem, maths:”;
cin>>mil>>eng>>phy>>chem>>maths;
}
void student::calculate( )
{
total=mil+eng+phy+chem+maths;
}
void student::disp( )
{
cout<<”Rollno is:”<<rollno;<<endl;
cout<<”Name is:”<<name<<endl;
cout<<”Total is:”<<total;
}
int main( )
{
student obj;
obj.readdata( );
obj.calculate( );
obj.disp( );
return 0;
}
Enter rollno: 2
Enter name: arun
Enter marks in MIL, eng, phy, chem, maths:40 50 90 70 60
Rollno is:2
Name is:arun
Total is:310