Skip to content

Commit

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

0 comments on commit c32d687

Please sign in to comment.