Gramin Technical And Management Campus
Department Of Computer Engineering
Subject/code: JPR/22412
Name: Ritesh Debadwar Batch: Co4IB Roll no:-69
DOP:- DOS:-
interface Shape
{
double getArea();
}
class Rectangle implements Shape
{
double length;
double width;
public Rectangle(double length, double width)
{
this.length = length;
this.width = width;
}
public double getArea()
{
return length * width;
}
}
class Circle implements Shape {
double radius;
public Circle(double radius) {
this.radius = radius;
}
public double getArea() {
return Math.PI * radius * radius;
}
}
public class Testsss5
{
public static void main(String[] args) {
Rectangle rectangle = new Rectangle(5.0, 3.0);
Circle circle = new Circle(4.0);
System.out.println("Area of Rectangle: " + rectangle.getArea());
System.out.println("Area of Circle: " + circle.getArea());
}
}