Assignment
Assignment
Emerging Sciences
Assignment
Spring 2022
Deadline
As Mentioned on
Google-Classroom
Guidelines
Questions should be in order.
Q1: Create a class for fraction that will store denominator and nominator. You must
provide the functionality of sum multiply subtract and divide.
For operations you must use operator overloading and friend function for input and
output. Make a diver function that will call all the functions.
Q2: Create a class for polynomials that will store a polynomial with a user defined
degree. Degree of a polynomial is the maximum number of power that it has.
You must provide the functionality of sum multiply subtract and divide. For operations
you must use operator overloading and friend function for input and output. Make a diver
function that will call all the functions.
Q3: Create a library system where you will have a class of books and students and the
librarian will operate through main function a student can get maximum 10 books from
library. and on late there will be a fine 5RS per hour and on return the system must tell
the fine on the book
Page 2 of 6
National University
of Computer & Emerging Sciences -Faisalabad
Q4: Write a class of shop with member variable ID, name, post, salary, status.
Post:
1. Owner
2. Salesman
3. Manager
Status: string type--- working / not working
In main function, you have to take array of 5 objects and overload the following
operators.
+ : (to calculate the sum of all employees)
- : (to update the working status)
* : (to increase the salary 10% of specific worker with his ID)
>> : (to input)
<< : (to display)
++ : (to increment in salary 5000)
--: (to decrement in salary 5000)
== : (to display all the employees have equal salary)
!= : (to display all the employees have unequal salary)
Q5:
1. Write a class Base having the following integer attributes:
• Base1
• Base2
• Base3(private)
Write a default constructor for Base that should initialize all the attributes to “0”. Write an overloaded
constructor that should initialize all the attributes to the passed integer. Write a display method to display
the attributes of Base class.
2. Publicly inherit a Derived class from Base class. Derived should have an integer attribute:
• Derived1
• Derived2(private)
Write a default constructor for Derived that should initialize all the attributes (inherited and self)to “1”. Write
an overloaded constructor that should initialize all the attributes to the passed integer. Write a display
method to display the attributes of Derived class.
Page 3 of 6
National University
of Computer & Emerging Sciences -Faisalabad
Q6:
Q7:
Page 4 of 6
National University
of Computer & Emerging Sciences -Faisalabad
Page 5 of 6
National University
of Computer & Emerging Sciences -Faisalabad
Q8: Write a program that Compare the two object that contains integer values that
demonstrate the overloading of equality (= =), less than (<), greater than (>), not equal ( !
= ),greater than or equal to (>=) and less than or equal to(<=) operators. Show the output
for if 2 numbers from 2 objects are equal, not equal, less than or greater than equal
Q9: (Polynomial Class) Develop class Polynomial. The internal representation of a Polynomial
is an array of terms. Each term contains a coefficient and an exponent, e.g., the term 2x4 has
the coefficient 2 and the exponent 4. Develop a complete class containing proper constructor
and destructor functions as well as set and get functions. The class should also provide the
following overloaded operator capabilities:
Q10: Create a class Mobile having Specification attributes and a friend function Compare.
Show a list of available mobiles to the user and compare them to help the user make a decision
to buy the better one. Put some intelligence in your program to predict him which one is the
better phone.
Page 6 of 6