Student Total Marks coderinme

Student Total Marks coderinme

Student Total Marks coderinme
Create a class named student with the following specifications:
Private members:
admno (int) to represent admission number
name (char) to represent name (max 20 characters)
marksEng (int) to represent marks in English
marksMaths (int) to represent marks in Maths
marksSc (int) to represent marks in Science
total (int) to represent total marks
compute () a function to compute sum of marks in English, Math, science
public member functions:
readData () to input the data for data members. It else invokes compute()
function to calculate total marks.
showData() to display all the data members on the computer screen.
Write a C++ program to use this class.

#include<iostream.h>
#include<conio.h>
#define MAX 50
class Student
{
int admno;
int marksEng;
int marksMaths;
int marksSc;
int total;
char name[MAX];
void compute()
{
total=marksEng+marksMaths+marksSc;
}
public:
void readData()
{
cout<<"enter admission number: ";
cin>>admno;
fflush(stdin);
cout<<"enter the name of student: ";
cin.getline(name,25);
cout<<"enter marks in english: ";
cin>>marksEng;
cout<<"enter marks in maths: ";
cin>>marksMaths;
cout<<"enter marks in science: ";
cin>>marksSc;
compute();
}
void showData()
{
cout<<endl;
cout<<"admission number: "<<admno<<endl;
cout<<"name of student: "<<name<<endl;
cout<<"marks in english: "<<marksEng<<endl;
cout<<"marks in maths: "<<marksMaths<<endl;
cout<<"marks in science: "<<marksSc<<endl;
cout<<"total marks: "<<total<<endl;
cout<<endl;
}
};
int main()
{
Student s1;
s1.readData();
s1.showData();
getch();
return 0;
}

For more programs in C++, visit our C++ Coder Archives

Student Total Marks coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.