Answer to Question #275412 in C++ for Priya

Question #275412

create a student class to store 3 subject marks .Overload the display() function to 1. Display total using 3 subject marks 2. Display average using the total.

1
Expert's answer
2021-12-04T04:31:02-0500
#include <iostream>
using namespace std;


//class definition
class Student 
{
	private:
		int a;
		int b;
        int c;
        int average;
	public:
		//member function declaration
		void readMarks(void);
		void printMarks(void);
		int display(void);
};
//member function definitions
void Marks::readMarks(void)
{
	cout<<"Enter first mark: ";
	cin>>a;
	cout<<"Enter second mark: ";
	cin>>b;	
    cout<<"Enter third mark: ";
	cin>>c;	
}


void Marks::printMarks(void)
{
	cout<<"Mark One= "<<a<<",Mark Two = "<<b<<" Mark Three"<<c<<endl;
}
int Marks::display(void)
{
    
	sum = (a+b+c);
    return sum;
}
int Marks::display(void)
{
    
	average = sum/3;
    return average;
}


//main function
int main()
{
	//declaring object
	Student s1;
	int add, average; //variable to store addition
	//take input
	s1.readMarks();
	//find addition
	add=num.display();
    //find average
	average=sum/3;
	//print numbers
   s1.printMarks();
	//print addition
	cout<<"Addition/sum= "<<sum<<endl;
    court<<" Average "<<average<<end1;
	
	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