0% found this document useful (0 votes)
137 views

Final Question Paper 07 Oct-2024

Uploaded by

samarthmahajan77
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Final Question Paper 07 Oct-2024

Uploaded by

samarthmahajan77
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Roll Number: ______________________

Thapar Institute of Engineering and Technology, Patiala


Department of Computer Science and Engineering
MID-Semester Examination
BE 3rd Sem UTA018: Object Oriented Programming
Date: 5 Oct 2024, Time: 11:00 AM Time: 2Hours, Max Marks:30

Instructors: Nidhi Kalra, Palika Chopra, Suresh Raikwar, Harpreet Singh, Seemu Sharma, Lokendera,
Tanu Goyal
Note: Attempt all questions (subparts) in sequence at one place. Assume missing data, if, any, suitably. Pencil work will
not be evaluated.
Q1 a) Design a class Triangle with private attributes: base and height. Implement 3
a public function compareArea(Triangle &t1, Triangle &t2) that compares
the areas of two triangles passed as arguments and returns the triangle with
the larger area.
b) Design a C++ program with a variable named int count that tracks both the
2
number of items and the number of customers in the same program.
Initialize the count variable with no. of items=20 and no. of customers=12,
respectively. In main(), display the no. of items only. Ensure that the
solution does not use classes and :: operator.
Q2 a) Design a Car class with private attributes: speed and fuel, and implement 3
a constructor that uses this pointer to initialize these attributes. Develop
all the necessary methods required to display the details.
b) Explain the following concepts in object-oriented programming with the
help of a suitable example:
2
i. Data Abstraction
ii. Polymorphism
Q3 5

You are provided with the ShoppingCart class, as shown above. Write the main()
function for the given class. Your task is to:
Take input from the user for the number of shopping carts (n) and dynamically
create an array of n ShoppingCart objects. Initialize the objects using the
parameterized constructor by taking the input at run-time. Display the details.
Finally, release the dynamically allocated memory for the shopping carts before the
program terminates.
Q4 Develop a Donation Management System in C++ that efficiently manages the 5
transfer of donations between accounts utilizing classes. The system consists of the

[P.T.O]
following components: Donor Class contains private data members: string
donor_name, double balance. Write the following functions in public section:
 set_details(string name, double amount)
 display()
 double get_balance()
Recipient Class contains the private data member: string recipient_name, double
account_balance, double amount_required needed by the recipient and the
following functions in public section:
 set_details(string name, double balance, double amount)
 display()
 double get_balance()
Additionally, the program includes the following function:
transfer (Donor &donor, Recipient &recipient, double amount)
This function facilitates the transfer of funds between a donor and a recipient. This
function will verify whether the donor has sufficient funds for the transfer. If the
donor has adequate funds, both the donor's and recipient's balances will be updated
accordingly. Complete the program using the above-mentioned conditions.
Q5 Implement the class with four private integer data members and public: showdata() 5
function for the below main() code snippet.

Q6 5

Design a C++ program to demonstrate multilevel inheritance using the following


classes: Class Company (Base Class) with attributes: company_name and
location. Class Team (Intermediate Class): Inherits from Company and adds
attributes: team_name and project. Class Developer (Derived Class): Inherits from
Team and adds attributes: developer_name and programming_language. Use a
parameterized constructors to initialize all the class attributes. Create an object
of Developer, and display details from all the classes: Company, Team, and
Developer.

You might also like