Java program to calculate and display area of a circle using method

Let’s see java program to calculate and display area of a circle using method.

Also read – circumference of a circle in java

Java program to calculate and display area of a circle using method

java program to calculate and display area of a circle using method

Here’s the java program to calculate area of circle using method,

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