OOP Assignment 2
OOP Assignment 2
Question # 03:
We want to calculate the total marks of each student of a class in Physics, Chemistry and
Mathematics and the average marks of the class. The number of students in the class are entered
by the user. Create a class named Marks with data members for roll number, name and marks.
Create three other classes inheriting the Marks class, namely Physics, Chemistry and
Mathematics, which are used to define marks in individual subject of each student. Roll number
of each student will be generated automatically.
Question # 04:
Consider a class Computer having Two fields (i.e. companyName, price) and A single function named
show() A class named Desktop inherits Computer class and adds fields representing color, monitor size,
and processor type and Override function named show() to display values of its all attributes A class named
Laptop inherits Computer class and adds fields representing color, size, weight, and processor type and
Override function named show() to display values of its all attributes In Main() instantiate objects of derived
classes to access respective show() functions to see the polymorphic behavior.
Question # 05:
Write a class Distance that holds distances or measurements expressed in feets and inches. This class has
two private data members:
Define a constructor that should have default parameters that can set all elements to 0. Moreover, define a
function called setMatrixValues(int matrixArray[3][3]) that can assign values of matrixArray (provided to
the function in argument) to the matrix array (data member of the class Matrix) of the class. Along with it,
define a function called displayMatrix() that can display all values of the matrix.
Moreover, you are instructed to construct a program that can perform operator overloading for the following
operators + (plus), - (minus), and == (equal).
Question # 07:
We want to create a class of Product that contains multiple private data members such as
END