Write A C Program To Implement The Multilevel In...
Write A C Program To Implement The Multilevel In...
My courses
My books My folder Career Life
home / study / engineering / computer science / computer science questions and answers / write a c++ program to implement the multilevel inhe…
Question: Write a C++ program to implement the Multilevel Inheritance … Post a question
Answers from our experts for your tough
homework questions
functions as:
0 questions remaining
data members and the member functions as:
Derive the class Marks from the class Student in public mode
Create the class Result with total marks (total), average (avg)
and My Textbook Solutions
grade(gr) as data members and the member functions as:
Expert Answer
If you have any doubts, please ask in the comments, I will try
to solve it as soon as possible. If you find my
answer helpful, do
UPVOTE.Thanks
#include<iomanip>
Home Study tools
My courses
My books My folder Career Life
#include<string.h>
class Student{
int snum;
string sname;
string deg;
public:
void getstud(){
cin>>snum;
fflush(stdin);
getline(cin,sname);
getline(cin,deg);
void showstud(){
};
protected:
int m1;
int m2;
int m3;
public:
void getmark(){
cin>>m1;
cin>>m2;
cin>>m3;
void showmark(){
cout<<"\nMark 1: "<<m1;
cout<<"\nMark 2: "<<m2;
cout<<"\nMark 3: "<<m3;
};
int total;
float avg;
char grade;
public:
void Calresult(){
total=m1+m2+m3;
avg=total/3.0;
cout<<"\nAverage is "<<avg;
void Calgrade(){
if(avg>=60) grade='A';
else grade='C';
cout<<"\nGrade: "<<grade;
void Showresult(){
cout<<"\nTotal: "<<total;
cout<<"\nAverage: "<<avg;
cout<<"\nGrade: "<<grade;
};
int main(){
Result x;
x.getstud();
x.getmark();
x.Calresult();
Sample Output:
Comment
Q: 1. Write a C++ program to implement the Multilevel Inheritance on the following. ► Create the class Student with
Student number (snum), Student(sname) and degree (deg) as data members and the member functions as: •
getstud(): gets snum, sname and deg. • showstud(): prints snum, sname and deg ► Create the class Marks with
marks in three subjects m1, m2, m3 as data members and the...
Q: i
need the solution in C++
A: See answer
Show more
COMPANY
CHEGG NETWORK
CUSTOMER SERVICE