Saturday, 15 November 2014

Find area of a circle in java programming

Using arithmetic operation in java programming we can calculate area of a circle. To calculate the area of circle we use a mathematical operation. That is if a circle have radios of ‘r’ and area of circle is ‘a’ then the equation become
a = pi * r2
Here pi is constant whose value is 3.1416 approximately. Now let’s write the program to find out the area of any circle.
public class circleArea {
public static void main(String args[]) {
double pi, r, a;
r = 5;
pi = 3.1416;
a = pi * r * r;
System.out.println("area of your circle " + a);
}
}
In above program we create a public class ‘circleArea’. Now in program all variable taken as double for proper calculation. We take the value of radius ‘r’ is 5. Now let’s see the output of above program
area of your circle 78.54



0 comments:

Post a Comment