Assgnment No.3
Assgnment No.3
Sahiwal Campus
(Department of Computer Science)
Assignment Spring-2024
Course Title: Object Oriented Programming Course Code: CSC241 Credit Hours: 3+1
Course Instructor: M. Fayez Afzaal Programme Name: BSSE
Semester: 3rd Batch: SP-23 Section: Date:
Time Allowed: Maximum Marks: 10
Student’s Name: Reg. No. CUI/ /SWL
Important Instructions / Guidelines:
Read the question paper carefully and answer the questions according to their statements.
Mobile phones are not allowed. Calculators must not have any data/equations etc. in their memory.
Q.no.1 Write a class Time that has three data member hour, minutes and seconds. The
class has following member functions:
A constructor to initialize the time.
Show function to show the time.
Overload ++ operator to increase the time by 1 minute.
Overload -- operator to decrease the time by 1 minute.
Q.no.2 Define a class for a bank account that includes the following data members:
Name of the depositor
Account number
Type of account
Balance amount in the account
The class also contains the following member functions:
A constructor to assign initial values
Deposit function to deposit some amount. It should accept the amount as
parameter
Withdraw function to withdraw an amount after checking the balance. It should
accept the amount as parameter.
Display function to display name and balance
Overload binary + operator that adds the balance of one account to another
account. It should accept an object as parameter and add the values of the
parameter to the calling object
Qno.3 Write a class Array that contains an array of integers as data member. The class
contains the following member functions:
A constructor that initializes the array element to -1.
Input function to input the values in the array.
Show function to display the values of the array.
Page 1 of 2
Overload == operator to compare the values of two objects. The overloaded
function returns 1 if all the values of both objects are same and returns 0
otherwise.
Q.no.4 Write a class Distance that has attributes of feet and inches. A constructor with
no parameters initializes data members to 0 and 0.0. A parametrized constructor that
assigns values to data members. A member function getdist() inputs the values and
function showdist() display the values. It has an overloaded operator ‘+’ that adds the
two distances, ‘-’ that subtracts the two distances and ‘*’ that product the two
distances. All overloaded operators must be declared inside the class and defined
outside the class. It should solve the statement dist5 = dist1 + dist2 - dist3 * dist4;
Page 2 of 2