OOP based problem for students marks coderinme

OOP based problem for students marks

In this example we will diplay students detail including marks name roll this is the good concepts of class object and methods.
OOP based problem for students marks
#include
#include
using namespace std;
int compute();
class student
{
private:
int admno;
char name[30];
int marksEng, marksMaths, marksSc, s;
int compute()
{
int sum;
sum=marksEng+marksMaths+marksSc;
return sum;
}
public:
void readData();
void showData();
};
void student::readData()
{
//compute();
cout<<"ENTER ADMISSION NUMBER:"<>admno;
cout<<"\n NAME OF STUDENT IS:"<>name;
cout<<"\n ENTER ENGLISH MARKS:"<>marksEng;
cout<<"\n ENTER MATHEMATICS MARKS:"<>marksMaths;
cout<<"\n ENTER SCIENCE MARKS:"<>marksSc;
s=compute();

// compute();
}
void student::showData()
{
cout<<"STUDENT ADMISSION NUMBER IS:"<<admno;
cout<<"\nSTUDENT NAME:"<<name;
cout<<"\nENGLISH MARKS:"<<marksEng;
cout<<"\nMATHEMATICS MARKS:"<<marksMaths;
cout<<"\nSCIENCE MARKS:"<<marksSc;
cout<<"\nSUM OF STUDENT'S MARKS: "<<s<<endl;

}
int main()
{
student s;
s.readData();
//compute();
s.showData();
return 0;
}

the output would be

ENTER ADMISSION NUMBER:
4323

NAME OF STUDENT IS:
fary

ENTER ENGLISH MARKS:
76

ENTER MATHEMATICS MARKS:
92

ENTER SCIENCE MARKS:
85
STUDENT ADMISSION NUMBER IS:4323
STUDENT NAME:fary
ENGLISH MARKS:76
MATHEMATICS MARKS:92
SCIENCE MARKS:85
SUM OF STUDENT’S MARKS: 253

So that was full OOP based problem for students marks

Leave a reply:

Your email address will not be published.