Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Every cylinder has a base and height, where the base is a circle. Design the cla

ID: 3740114 • Letter: E

Question

Every cylinder has a base and height, where the base is a circle. Design the class Cylinder that can capture the properties of a cylinder and perform the usual operations on a cylinder. Derive this class from the class Circle. Please do the following:

Some of the operations that can be performed on a cylinder are as follows: calculate and print the volume, calculate and print the surface area, set the height, set the radius of the base and set the center of the base.

Write a test program to test your program

----------------------------------------------------------------------

class Circle extends Point{
  
private double radius;
  
Circle(double xValue, double yValue, double radius){
super(xValue, yValue);
this.radius = radius;
}

public double getRadius() {
return radius;
}

public void setRadius(double radius) {
this.radius = radius;
}

public double getArea(){
return Math.PI*radius*radius;
}

public void printArea(){
System.out.format("Area of the circle: %.2f ",getArea());
}

public double getCircumference(){
return Math.PI*2*radius;
}

public void printCircumference(){
System.out.format("Circumference of the circle: %.2f ",getCircumference());
}
}

Explanation / Answer

public class Cylinder extends Circle { private double height; Cylinder(double xValue, double yValue, double radius, double height) { super(xValue, yValue, radius); } public double getHeight() { return height; } public void setHeight(double height) { this.height = height; } @Override public double getArea() { return super.getCircumference() * height; } @Override public void printArea() { System.out.format("Area of the cylinder: %.2f ", getArea()); } public double getVolume() { return super.getArea() * getHeight(); } public void printVolume() { System.out.format("Volume of the cylinder: %.2f ",getVolume()); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote