Interface
Excersise: 6
Develop a Program using Interface.
Program
import java.io.*;
import java.lang.*;
interface demo
{
double pi=3.14;
void area(double r);
}
class circle implements demo
{
double radius;
double carea;
public void area(double r)
{
radius=r;
carea=pi*radius*radius;
System.out.println("Area of Circle:"+carea);
}
}
class Intdemo
{
public static void main(String arg[])throws IOException
{
DataInputStream din=new DataInputStream(System.in);
System.out.println("Enter the Value of Radius:");
double ra=Double.parseDouble(din.readLine());
circle c=new circle();
c.area(ra);
}
}
Output
Post a Comment
Thanks for your comments. Please be visit and given positive review on our site.