Question #213007

Define a class Student with data members as rollno and name. Derive a class Fees from student that has a data member fees and functions to submit fees and generate receipt. Derive another class Result from Student that displays the marks and grade obtained by the student. Write a program that extends the class Result so that the final result of the Student is evaluated based on the marks obtained in tests, activities and sports


Expert's answer

using namespace std;


class Student
{
	public:
		unsigned rollno;
		string name;
	public:
		void set_data(unsigned int rn, string s)
		{
			rollno = rn;
			name = s;
		}
		
};


// Derived class
class Fees: public Student
{
    public:
   		unsigned int Fee;
   	public:
	   void SubmitFee(unsigned int f)
	   { 
       		 Fee = f;
       }
       void GenerateReport(void)
       {
       		cout<<"\n\nFee Report:";
			cout<<"\nName     : "<<name;
       		cout<<"\nRoll No. : "<<rollno;
       		cout<<"\nFee      : "<<Fee;
	   }
};


// Derived class
class Result: public Fees//Student
{
    public:
   		unsigned int MarksTests;
   		unsigned int MarksActivities;
   		unsigned int MarksSports;
   		unsigned int TotalMarks;
   		char Grade;
   	public:
	   void set_marks(unsigned int ms, unsigned int ma, unsigned msp)
	   { 
			MarksTests=ms;
       		MarksActivities = ma;
       		MarksSports = msp;
       		TotalMarks = MarksTests + MarksActivities + MarksSports;
			if(TotalMarks>80)
			{
				Grade = 'A';
			}
			else if(TotalMarks>70 && TotalMarks<=80)
			{
				Grade = 'B';
			}
			else if(TotalMarks>60 && TotalMarks<=70)
			{
				Grade = 'C';
			}
			else if(TotalMarks>50 && TotalMarks<=60)
			{
				Grade = 'D';
			}
			else{
				Grade ='E';
			}
       }
       void GenerateResult(void)
       {
       		cout<<"\n\nResult Card";
       		cout<<"\nMarks in Tests     : "<<MarksTests;
       		cout<<"\nMarks in Activities: "<<MarksTests;
       		cout<<"\nMarks in Sports    : "<<MarksTests;
       		cout<<"\nTotal Marks        : "<<TotalMarks;
       		cout<<"\nFinal Grade        : "<<Grade;
	   }


};
main(void)
{
	Result S1,S2,S3;
    S1.set_data(111,"ABC");
    S1.SubmitFee(100);
    S1.GenerateReport();
    S1.set_marks(30,40,80);
    S1.GenerateResult();


    S2.set_data(222,"LMN");
    S2.SubmitFee(100);
    S2.GenerateReport();
    S2.set_marks(67,88,99);
    S2.GenerateResult();


    S3.set_data(333,"XYZ");
    S3.SubmitFee(100);
    S3.GenerateReport();
    S3.set_marks(89,80,98);
    S3.GenerateResult();
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS