0% found this document useful (0 votes)
7 views3 pages

Model Lab - 1 Questions

The document outlines various programming tasks involving object-oriented concepts in C++, including class creation, inheritance, polymorphism, and operator overloading. It covers the design of classes for courses, banks, employees, reservations, fast food, payroll, marks, and a piggie bank, with specific functionalities and methods required for each. Additionally, it emphasizes the implementation of constructors, member functions, and the use of static members where applicable.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Model Lab - 1 Questions

The document outlines various programming tasks involving object-oriented concepts in C++, including class creation, inheritance, polymorphism, and operator overloading. It covers the design of classes for courses, banks, employees, reservations, fast food, payroll, marks, and a piggie bank, with specific functionalities and methods required for each. Additionally, it emphasizes the implementation of constructors, member functions, and the use of static members where applicable.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1. 1.

Create a base class for Course with attributes (Course_name, id, Instructor)
and methods to get and display_details.
2. Create derived classes for Online_Course of items (e) with additional
attributes no_of_weeks, and price with methods as needed.
3. Utilize polymorphism to handle get() and display() method for
Online_Course by overriding methods in derived classes.
4. Implement functions to add items, display item details using the
display_details method.

2. A boy has his money deposited $1000, $1500 and $2000 in banks-Bank A, Bank B
and Bank C respectively. We have to print the money deposited by him in a
particular bank.Create a class 'Bank' with a function 'getBalance' which returns 0.
Make its three subclasses named 'BankA', 'BankB' and 'BankC' with a function with
the same name 'getBalance' which returns the amount deposited in that particular
bank. Call the function 'getBalance' by the object of each of the three banks.Using
the inheritance concepts.

3. Design a class Employee with private member variables id, name, and salary,
representing the employee ID, name, and salary, respectively. Implement the
following functionalities: A constructor to initialize the employee ID, name, and
salary. A static member variable totalEmployees to keep track of the total number of
employees. A static member function getTotal Employees() to return the total
number of employees. A member function display() to display the details of the
employee. Write the C++ code for the Employee class along with the
implementation of the static member variable and function.
4. 1. Create a base class for reservation details with attributes (User, Regular
user, Admin user).
2. Create derived classes for specific types of reservation (e.g. Event,
ConcertEvent, Conference Event) with additional attributes and
methods.
3. Use polymorphism to handle different ticket types by overriding
methods in derived classes.
4. Implement a function to add ticket details and display the information
using the display_details method.
5. Create a C++ program that demonstrates constructor overloading within a class.
Specifications: Class construct: The class should have a member variable area of
type float to store the calculated area.Two constructors should be
defined:Constructor with no parameters: Initializes the area member variable to 0.
Constructor with two integer parameters (int a and int b): Calculates the area by
multiplying a and b and assigns the result to the area member variable. Method
disp():Displays the value of the area member variable.Main Function:Demonstrates
constructor overloading by creating instances of the construct class using both
constructors.Calls the disp() method for each instance to display the value of the
area member variable.

6. 1. Create a base class for Fast_Food with attributes (Food_name, id,Cost) and
methods to get and display_details with array of objects.
2. Create derived classes for Bill with additional attributes Quantity and
Total_Price with methods as needed.
3. Utilize polymorphism to implement methods in Bill to book orders() and
cancel orders().
4. Implement functions to display the bill of the person at the end of booking.
7. Write a function power() to raise a number m to power n.The function takes a double
value for m and int value for n and returns the result correctly.Use a default value of
2 for n to make the function to calculate the squares when this argument is
omitted.Write a main that gets the value of m and n from the user to test the function.

8. Consider a C++ program that utilizes operator overloading through a friend function
to perform addition on complex numbers. The Complex class has private data
members real and img, a constructor to initialize these members, and a member
function. Display to print the complex number. The operator + function is
implemented as a friend function for adding two complex numbers.
9. Create a class named Shape with a function that prints "This is a shape". Create
another class named Polygon inheriting the Shape class with the same function that
prints "Polygon is a shape". Create two other classes named Rectangle and Triangle
having the same function which prints "Rectangle is a polygon" and "Triangle is a
polygon" respectively. Again, make another class named Square having the same
function which prints "Square is a rectangle".Now, try calling the function by the
object of each of these classes
10. A class has an integer data member 'i' and a function named 'printNum' to print the
value of 'i'. Its subclass also has an integer data member 'j' and a function named
'printNum' to print the value of 'j'. Make an object of the subclass and use it to assign
a value to 'i' and to 'j'. Now call the function 'printNum' by this object.
11. 1. Create a base class for reservation details with attributes (User, Regular
user, Admin user).
2. Create derived classes for specific types of reservation (e.g. Event,
ConcertEvent, Conference Event) with additional attributes and
methods.
3. Use polymorphism to handle different ticket types by overriding
methods in derived classes.
4. Implement a function to add ticket details and display the information
using the display_details method.
12. 1. Create a base class for payroll details with attributes (employee_id, salary, tax,
deductions) and a method (display_details).
2. Create derived classes for specific types of payroll (e.g., Monthly, Weekly) with
additional attributes and methods.
3. Use polymorphism to handle different payroll types by overriding methods in
derived classes.
4. Implement a function to add payroll details and display the information using
the display_details method

13. 1. Create a base class for Fast_Food with attributes (Food_name, id,Cost) and
methods to get and display_details with array of objects.
2. Create derived classes for Bill with additional attributes Quantity and
Total_Price with methods as needed.
3. Utilize polymorphism to implement methods in Bill to book orders() and
cancel orders().
4. Implement functions to display the bill of the person at the end of booking
14. 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 is 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.

15. Suppose you have a Piggie Bank with an initial amount of $50 and you have to add
some more amount to it. Create a class 'AddAmount' with a data member named
'amount' with an initial value of $50. Now make two constructors of this class as
follows:
1 - without any parameter - no amount will be added to the Piggie Bank
2 - having a parameter which is the amount that will be added to the Piggie
Bank
Create an object of the 'AddAmount' class and display the final amount in the Piggie
Bank

Program split up Total


(100)
Problem Identification Implementation (40) Execution & Output (30) Viva
(20)
(10)

You might also like