Calculate Circle Area using Java Example

 
Area of a circle = pi * r * r.
where:
r is the radius of the circle.
pi is a mathematical constant.

Program to Calculate Circle Area using Java.

/**
 * Program to Calculate Circle Area using Java Example.
 * @author W3spoint
 */
public class CirleAreaExample {
	static void circleArea(int radius){
		 double area = Math.PI * radius * radius;
         //Print Circle Area.
         System.out.println("Circle area: " + area);
	}	
 
	public static void main(String args[]){ 
		//method call 
		circleArea(20); 
	}
}

Output:

Circle area: 1256.6370614359173

 

Content Protection by DMCA.com
Please Share