You are on page 1of 4

PCA-1 Examination

Paper Name : Object Oriented Programming Lab


Date of Exam : 30th August, 2023
Semester : 5th
Paper Code : PCC-CS593
Academic Session : 2023-24

SET 6
Problem Statement:
Develop a library management system that keeps track of books and their
information. Create a class named Book with the following attributes:

● title (String): The title of the book.


● author (String): The author of the book.
● isbn (String): The ISBN (International Standard Book Number) of the book.
● publishedYear (int): The year the book was published.

Implement multiple constructors to provide flexibility in creating Book objects:

● Default Constructor: Initializes the attributes to default values (e.g., empty


strings and 0 for the year).
● Constructor with Title and Author: Initializes the title and author attributes and
sets isbn and publishedYear to default values.
● Constructor with Title, Author, ISBN, and Published Year: Initializes all
attributes with provided values.

In addition to the constructors, implement a displayInfo() method that prints the


book's information to the console.

Tasks to be Performed:

● Design the Book class according to the requirements above.


● In the Main class, demonstrate the use of the different constructors by creating
several Book objects with different sets of information.
● Display the information of each book using the displayInfo() method.

User input must be taken from command line arguments in all the above cases.
PCA-1 Examination
Paper Name : Object Oriented Programming Lab
Date of Exam : 30th August, 2023
Semester : 5th
Paper Code : PCC-CS593
Academic Session : 2023-24

SET 5

Problem Statement:
You are tasked with designing a class Rectangle to represent rectangles in a 2D plane.
The class should have two private attributes: width and height, representing the
dimensions of the rectangle.

The class should have the following attributes and functionalities:

● A constructor that initializes the width and height of the rectangle based on
user input.
● A constructor that initializes the width of the rectangle (assumes height is 1).
● A constructor that initializes the height of the rectangle (assumes width is 1).
● A constructor that initializes the rectangle with no parameters (sets width and
height to 1).
● A constructor that takes a single parameter side and creates a square rectangle
with both width and height set to the value of side.

Additionally, the class should provide methods to calculate the area and perimeter of
the rectangle.

Tasks to be completed

● Demonstrate the use of constructor overloading by creating instances of the


class using different constructor variations.
● Calculate and display the area and perimeter of each rectangle.

User input must be taken from command line arguments in all the above cases.
PCA-1 Examination
Paper Name : Object Oriented Programming Lab
Date of Exam : 30th August, 2023
Semester : 5th
Paper Code : PCC-CS593
Academic Session : 2023-24

SET 7
Problem Statement:

You are tasked with creating a class named Converter that provides methods for
converting temperature values between Celsius and Fahrenheit scales.

Class Requirements: The class Converter should have the following methods:

● Method that converts a double temperature value from Celsius to


Fahrenheit and returns the result.
● Method that converts a double temperature value from Fahrenheit to
Celsius and returns the result.
● Method that converts an integer temperature value from Celsius to
Fahrenheit and returns the result.
● Method that converts an integer temperature value from Fahrenheit to
Celsius and returns the result.

Tasks to be completed:

● Design the Converter class according to the requirements above.


● Create a Main class to demonstrate the usage of the Converter class.
● In the Main class, create an instance of the Converter class.
● Demonstrate the use of the different overloaded methods by performing
temperature conversions using both double and integer values.
● Display the results of the temperature conversions.

Formula for conversion:

● Temperature in Fahrenheit (°F) = (Temperature in Celsius (°C) * 9/5) + 32


● Temperature in Celsius (°C) = (Temperature in Fahrenheit (°F) - 32) * 5/9
PCA-1 Examination
Paper Name : Object Oriented Programming Lab
Date of Exam : 30th August, 2023
Semester : 5th
Paper Code : PCC-CS593
Academic Session : 2023-24

SET 8
Problem Statement:

You are tasked with creating a class Calculator that provides various methods for
performing arithmetic operations. The class should support both constructor
overloading and method overloading to accommodate different data types.

Class Requirements: The Calculator class should have multiple constructors to


initialize the object:

● A default constructor.
● A constructor that takes two integers to initialize a specific operation range.
● A constructor that takes two double values to initialize a specific operation
range.

Implement the following methods in the Calculator class:

● add: Accepts two integers and returns their sum.


● add: Accepts two double values and returns their sum.
● multiply: Accepts two integers and returns their product.
● multiply: Accepts two double values and returns their product.

Tasks to be completed:

● Design the Calculator class according to the requirements above.


● Demonstrate the use of constructor overloading by creating different
instances of the Calculator class using the various constructors.
● Demonstrate the use of method overloading by performing arithmetic
operations using different combinations of data types.

You might also like