Java program to calculate area of circle using method

Hey guys!! How are you doing.. Welcome to flower brackets. Let’s see java program to calculate area of circle using method.

Also read – circumference of a circle in java

Java program to calculate area of circle using method

Java program to calculate area of 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

Related Posts