Java program to calculate area of circle using method

In this post we are going to learn java program to calculate area of circle using method.

Java program to calculate area of circle using method

java program to calculate area of circle using method

To calculate the area of a circle using a method, first we have to write a method which accepts radius as parameter to calculate area of circle.

Also read – circumference of a circle in java

Here’s the java program for program to find area of a circle,

import java.util.Scanner;
public class AreaOfCircleMethod 
{
   public static void main(String[] args) 
   {
      Scanner sc = new Scanner(System.in);  
      System.out.println("Please enter radius : ");
      double radius = sc.nextDouble();
      double area = calculateArea(radius);  
      System.out.println("Area of circle : " + area);
      sc.close();
   }
   static double calculateArea(double r)
   {
      return (22 * r * r) / 7;
   }
}

Output:

Please enter radius : 5
Area of circle : 78.57142857142857