Skip to content

Commit

Permalink
Abstract Methods and Classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijaykumar204 committed Sep 1, 2023
1 parent 5c6192e commit 8d20863
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions abstract.java
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();
}
}

0 comments on commit 8d20863

Please sign in to comment.