File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
3+ interface Shape {
4+ int Area ();
5+ }
6+ class Rectangle implements Shape {
7+ int l ,b ;
8+ Rectangle (int l ,int b )
9+ {
10+ this .l =l ;
11+ this .b =b ;
12+ }
13+ @ Override
14+ public int Area () {
15+ return l *b ;
16+ }
17+ }
18+ class Square implements Shape {
19+ int s ;
20+ Square (int s )
21+ {
22+ this .s =s ;
23+ }
24+ @ Override
25+ public int Area () {
26+ return s *s ;
27+ }
28+ }
29+ class FindAreaMain {
30+ public static void main (String [] args ) {
31+ Scanner ob =new Scanner (System .in );
32+ System .out .println ("Enter length and breadth of Rectangle: " );
33+ Rectangle r =new Rectangle (ob .nextInt (),ob .nextInt ());
34+ System .out .println ("Enter side of Square: " );
35+ Square s =new Square (ob .nextInt ());
36+ System .out .println ("Area of Rectangle: " +r .Area ());
37+ System .out .println ("Area of Square: " +s .Area ());
38+ ob .close ();
39+ }
40+ }
41+
You can’t perform that action at this time.
0 commit comments