Announcement:

This is just the beginning of this blog, please don't copy any of my posts.

Sunday, 23 December 2012

[Java] Program to calculate area of Circle and display it

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[])
{
Circle c=new Circle(10);
c.area();
c.display();
}  }

Share it Please

Pankaj Gaikar

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

Copyright @ 2013 Pune University Bachelor of Engineering . Designed by Pankaj Gaikar | Love for The Tricks Machine