public class Circle {
private double radius;
private double area;
public Circle() {
radius=1;
}
public double getRadius() {
return radius;
}
public Circle(double area) {
this.area = area;
}
public double getArea() {
return area=getRadius()*getRadius()*3.14;
}
public void setRadius(double radius) {
this.radius = radius;
}
}
public class Cylinder extends Circle{
private double length;
public Cylinder() {
length=1;
}
public Cylinder(double length) {
this.length = length;
}
public Cylinder(double area, double length) {
super(area);
this.length = length;
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
public void findVolume(){
double volume = getArea() *getLength();
System.out.println(volume);
}
}
public class CylinderTest {
public static void main(String[] args) {
Cylinder c = new Cylinder();
c.setRadius(3);
c.setLength(3);
c.findVolume();
}
}