-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path11.java
More file actions
46 lines (45 loc) · 1.1 KB
/
11.java
File metadata and controls
46 lines (45 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.*;
interface Shape
{
public void area(float l , float b);
public void perimeter(float l, float b);
}
class Circle implements Shape{
public void area(float r,float r1)
{
System.out.println("The area of circle is "+(3.14*r*r1));
}
public void perimeter(float r,float r1)
{
System.out.println("The perimeter of circle is "+(3.14*2*r));
}
}
class Rectangle implements Shape
{
public void area(float l,float b)
{
System.out.println("The area of rectangle is "+(l*b));
}
public void perimeter(float l,float b)
{
System.out.println("The perimeter of rectangle is "+(2*(l+b)));
}
}
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter the radius of the circle");
float r = sc.nextFloat();
Circle ob = new Circle();
ob.area(r,r);
ob.perimeter(r,0);
System.out.println("Enter the length and breadth of the Rectangle");
float l = sc.nextFloat();
float b = sc.nextFloat();
Rectangle ob1 = new Rectangle();
ob1.area(l,b);
ob1.perimeter(l,b);
}
}