Define a class Circle having data members pi and radius. Initialize and display values of data members also calculate area of Circle and display it.
class Circle
{
int radius;
double PI=3.14,area;
Circle(int m)
{
radius=m;
}
void area()
{
area=PI*radius*radius;
}
void display()
{
System.out.println("Radius of circle="+radius);
System.out.println("Area of circle="+area);
}
public static void main(String args[])
{
public static void main(String args[])
{
Circle c=new Circle(10);
c.area();
c.display();
} }
Pankaj Gaikar is a
professional blogger
from Pune, India who writes on Technology, Android,
Gadgets, social media and latest tech updates at
Punk Tech
,
Being Android
&
Shake The Tech
. Email me
HERE
0 comments :
Post a Comment