Answer to Question #214006 in C++ for Hemambar

Question #214006

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.


1
Expert's answer
2021-07-13T13:36:03-0400
#include <iostream>
#include <string>




using namespace std;








class Student
{
private:
	string rollno;
	string name;
public:
	void setRoll(string rn){
		rollno = rn;
		
	}
	void setName(string n){
		name = n;
		
	}
	string getName(){
		return name;
	}
	string getRoll(){
		return rollno;
	}
};




class Fees: public Student
{
public:
	double fees;
public:
	
	void submit(int fe){ 
		fees = fe;
	}
	double getFees(){
		return fees;
	}
	void Receipt()
	{
		cout<<"Fee Receipt:\n"<<"Roll No: "<<getRoll()<<"\n"<<"Name: "<<getName()<<"\n"<<"Fee: "<<getFees()<<"\n";
	}
};




class Result: public Student
{
private:
	double tests, activities, sports;


public:
	Result(double t, double a, double s){
		tests = t;
		activities  = a;
		sports = s;
	}
	double getTests(){
		return tests;
	}
	double getSports(){
		return sports;
	}
	double getActivity(){
		return activities;
	}
	void Receipt(void)
	{
		double total = getActivity() + getSports() + getTests();
		double average=total /3 ;
		char grade;
		if(average>=90)
		{
			grade = 'A';
		}
		else if(average>=80 && average<90)
		{
			grade = 'B';
		}
		else if(average>=70 && average<80)
		{
			grade = 'C';
		}
		else if(average>=60 && average<70)
		{
			grade = 'D';
		}
		else{
			grade = 'F';
		}
		
		cout<<"\n\nMarks Receipt:"<<"\nMarks in Tests: "<<tests<<"\n"<<"Marks in Activities: "<<activities<<"\n";
		cout<<"Sports: "<<sports<<"\n"<<"Grade: "<<grade<<"\n\n";
	}
};
int main(void)
{
	Result r1(80,90,89);


	r1.Receipt();




	












	system("pause");
	return 0;
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS