interface Shape {
double calculateArea();
}
interface CircleProperties {
double calculatePerimeter();
}
class Circle implements Shape, CircleProperties {
private double radius;
public Circle(double radius) {
this.radius = radius;
}
public double calculateArea() {
return Math.PI * radius * radius;
}
public double calculatePerimeter() {
return 2 * Math.PI * radius;
}
}
public class CircleCalculator {
public static void main(String[] args) {
Circle myCircle = new Circle(5.0);
System.out.println("Area of the circle: " + myCircle.calculateArea());
System.out.println("Perimeter of the circle: " + myCircle.calculatePerimeter());
}
}
No comments:
Post a Comment