Answer to Question #261101 in C++ for Asim

Question #261101

Write a program having a base class Student with data members rollno, name and


Class define a member functions getdata() to input values and another function


putdata() to display all values. A class Test is derived from class Student with data


members T1marks, T2marks, T3marks, Sessional1, Sessional2, Assignment and Final.


Also make a function getmarks() to enter marks for all variables except Final and also


make a function putmarks() to display result. Make a function Finalresult() to


calculate value for final variable using other marks. Then display the student result


along with student data.

1
Expert's answer
2021-11-04T16:28:39-0400
#include <string>
#include <iostream>


using namespace std;


class Student
{
	int rollno;
	string name;
public:
	void getdata()
	{
		cout << "Please, enter the name of student: ";
		cin >> name;
		cout << "Please, enter the rollnumber of student: ";
		cin >> rollno;
	}
	void putdata()
	{
		cout << "\nData about the student:"
		     << "\nRollnumber: " << rollno
			 << "\nName: " << name;
	}
};


class Test :public Student
{
	int T1marks;
	int T2marks;
	int T3marks;
	int Sessional1;
	int Sessional2;
	int Assignment;
	double Final;
public:
	void getmarks()
	{
		cout << "\nPlease, enter T1marks: ";
		cin >> T1marks;
		cout << "Please, enter T2marks: ";
		cin >> T2marks;
		cout << "Please, enter T3marks: ";
		cin >> T3marks;
		cout << "Please, enter Sessional1: ";
		cin >> Sessional1;
		cout << "Please, enter Sessional2: ";
		cin >> Sessional2;
		cout << "Please, enter Assignment: ";
		cin >> Assignment;
	}


	void putmarks()
	{
		cout<< "\nMarks of student:"
			<< "\nT1marks: " << T1marks
			<< "\nT2marks: " << T2marks
			<< "\nT3marks: " << T3marks
			<< "\nSessional1: " << Sessional1
			<< "\nSessional2: " << Sessional2
			<< "\nAssignment: " << Assignment
			<< "\nFinal: " << Final;
	}
	void Finalresult()
	{
		Final =(double)(T1marks + T2marks + T3marks +
			Sessional1 + Sessional2 + Assignment) / 6;
	}
};
int main()
{
	Test t;
	t.getdata();
	t.getmarks();
	t.Finalresult();
	t.putdata();
	t.putmarks();
}

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
APPROVED BY CLIENTS