Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Object Oriented Programming

Assignment #3(09-12-2023)
Due Date: Saturday December 16, 2023 9:00 am
Instructor: Dr. Javid
Note: The deadline is hard, late submission and copied solutions will
credit zero marks. The Demos of this assignment will be conducted on 16th
December, 2023 in the 2nd class(Lab). (Comment your program properly,
write down your Name, Registration No. at the top of .cpp file as comment.
Take care of indentation when writing program.)

Task-1
We have a class named Distance having two private data members such as feet (integer),
inches(float), one constructor (parameterized) to initialize the data members, one input
function to input values to the data members, one Display function to show the distance
(inches and feet). The distance 5 feet and 6.4 inches should be displayed as 5’- 6.4”. Then
add the two objects of Distance class and then display the result (the + operator should be
overloaded). You should also take care of inches if its more than 12 then the inches
should be decremented by 12 and feet to be incremented by 1. Also overload the > and =
= operator for comparing the two objects of distance class. Create objects in main
function to validate your code.

Task-2
We have a class named ComplexNumber having two private data members such as
realPart (integer), imaginaryPart(int), one constructor (default) to initialize the data
members to 0, one set function to set the values of the data members(using the
parameters), one Display( ) function to show the Complex number ( 4 realPart, 6
imaginaryPart ) such as 4+6i , and if imaginary part is –ve then display as 4 – 6i. Then
add the two objects of ComplexNumber class and then display the result (the + operator
should be overloaded. Or you can add without overloading the + operator.

You might also like