You are on page 1of 2

CSII-Lab Manual

Week 4 Lab3 Programming


Problem 1
a) Cylinder
6 Marks
Create a class called Cylinder in a file whose name is
Cylinder.java
Let the Cylinder have height and radius(make them private)
Support initialization using default & parameterized constructors
Use getters to access the attributes
Write methods to
o Display the attributes
o Find volume of the cylinder(V = PI * r * r* h)
b) Cone
6 Marks
Similarly create another class Cone in a file called Cone.java
Let the cone have height and radius(make them private)
Support initialization using default & parameterized constructors
Use getters to access the attributes
Write methods to
o Display the attributes
o Find volume of the cone(V=1/3 PI * r * r * h)
c) Cuboid
6 Marks
Create a class called Cuboid in a file whose name is Cuboid.java
Let the Cuboid have length, breadth & height(make them
private)
Support initialization using default & parameterized constructors
Use getters to access the attributes
Write methods to
o Display the attributes
o Find volume of the cuboid (V = l * b * h)

Department Of Computer Science and Engineering

Page 1

CSII-Lab Manual

Problem 2
Write the Client code to

12 Marks

Create 3 cylinders. One initialized using default constructor and the


other two using parameterized constructor
Use the display method of Cylinder class and display the attributes
of all the three cylinders
Create a cone object and a cuboid object using the respective
parameterized constructors
Find and display the volumes of all the objects created
Problem 3 (Additional take home assignment-Not for evaluation)
Students can write this code in their observation and get it corrected
in the following week.
In the cylinder class add methods to
Resize the cylinder given a scaling factor
Compare whether 2 cylinders are the same
In the client class, add code to demonstrate the same

Department Of Computer Science and Engineering

Page 2

You might also like