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

Week 4 - Lab3 Programming Problem 1

The document outlines a lab assignment to create classes for geometric shapes including cylinders, cones, and cuboids. Students are asked to write classes for each shape with private height and radius/length/breadth attributes, default and parameterized constructors, getter methods, and methods to display attributes and calculate volume. For cylinders, additional methods are suggested to resize by a scaling factor and compare two cylinders. The client code problem requires creating objects of each shape class, displaying attributes, finding volumes, and demonstrating cylinder resizing and comparison.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Week 4 - Lab3 Programming Problem 1

The document outlines a lab assignment to create classes for geometric shapes including cylinders, cones, and cuboids. Students are asked to write classes for each shape with private height and radius/length/breadth attributes, default and parameterized constructors, getter methods, and methods to display attributes and calculate volume. For cylinders, additional methods are suggested to resize by a scaling factor and compare two cylinders. The client code problem requires creating objects of each shape class, displaying attributes, finding volumes, and demonstrating cylinder resizing and comparison.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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