Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface Shape {
- double area();
- double perimeter();
- }
- class Circle implements Shape {
- private double radius;
- public Circle(double radius) {
- this.radius = radius;
- }
- @Override
- public double area() {
- return Math.PI * radius * radius;
- }
- @Override
- public double perimeter() {
- return 2 * Math.PI * radius;
- }
- }
- public class Pr2c {
- public static void main(String args[]) {
- Circle c = new Circle(12.0);
- System.out.println("Circle Area:" + c.area());
- System.out.println("Circle Perimeter:" + c.perimeter());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement