-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d20863
commit c32d687
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import java.io.*; | ||
|
||
interface shape | ||
{ | ||
|
||
public void printArea(); | ||
} | ||
class rectangle implements shape | ||
{ | ||
public void printArea() throws Exception | ||
{ | ||
int l,b; | ||
DataInputStream d=new DataInputStream(System.in); | ||
System.out.println("enter the length"); | ||
l=Integer.parseInt(d.readLine()); | ||
System.out.println("enter the breadth"); | ||
b=Integer.parseInt(d.readLine()); | ||
|
||
System.out.println("AREA OF RECTANGLE="+(l*b)); | ||
} | ||
} | ||
class triangle implements shape | ||
{ | ||
public void printArea() throws Exception | ||
{ | ||
int l,b; | ||
DataInputStream d=new DataInputStream(System.in); | ||
System.out.println("enter the length"); | ||
l=Integer.parseInt(d.readLine()); | ||
System.out.println("enter the height"); | ||
b=Integer.parseInt(d.readLine()); | ||
|
||
System.out.println("AREA OF TRIANGLE="+(0.5f*l*b)); | ||
} | ||
} | ||
class circle implements shape | ||
{ | ||
public void printArea() throws Exception | ||
{ | ||
int l,b; | ||
DataInputStream d=new DataInputStream(System.in); | ||
System.out.println("enter the radius"); | ||
l=Integer.parseInt(d.readLine()); | ||
|
||
|
||
System.out.println("AREA OF CIRCLE="+(3.14f*l*l)); | ||
} | ||
} | ||
class m | ||
{ | ||
public static void main(String v[]) throws Exception | ||
{ | ||
rectangle r=new rectangle(); | ||
r.printArea(); | ||
triangle t=new triangle(); | ||
t.printArea(); | ||
circle c=new circle(); | ||
c.printArea(); | ||
} | ||
} |