Professional Documents
Culture Documents
Tutorial 9 - Writing Classes
Tutorial 9 - Writing Classes
Cylinder
- diameter: double
- height: int
+ Cylinder (d: double, h: int)
+ details(): void
Area Cylinder: π r2 x 2 + π d x h
Volume Cylinder: π r2 x h
1. Download the Cylinder.java file from CANVAS and complete the class by doing the tasks
use. The dimensions of the tanks are [diameter: 20m, height: 15m],
18m]. Write a program called CreateTanks that uses the Cylinder object to map each
a. Create Cylinder objects called tank1, tank2 and tank3 for each of the crude
oil tanks.
b. Given that the tanks are filled with crude oil print total volume of oil being
stored.
1
c. If of tank2 is emptied, how much crude oil remains in the tank.
3
d. Whenever a tank is empty the inside walls must be painted. If tank1 is empty
e. When routine maintenance is done the details of the tanks must be known. Print