-
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
5c6192e
commit 8d20863
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.*; | ||
|
||
abstract class shape | ||
{ | ||
int l,b; | ||
abstract void printArea(); | ||
} | ||
class rectangle extends shape | ||
{ | ||
void printArea() throws Exception | ||
{ | ||
|
||
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 extends shape | ||
{ | ||
void printArea1() throws Exception | ||
{ | ||
|
||
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 extends shape | ||
{ | ||
void printArea2() throws Exception | ||
{ | ||
|
||
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.printArea1(); | ||
circle c=new circle(); | ||
c.printArea2(); | ||
} | ||
} |