# Find the Area of a Circle in Java Program

In this article, we will understand how find the area of a circle. Area of a circle is calculated by using the formula −

pie*radius*radius.
i.e.
πr2
Where π = 3.14 and r is the radius of the circle.

Below is a demonstration of the same −

Input

Suppose our input is −

Radius of the circle : 5

Output

The desired output would be −

The Area of Circle is: 78.57142857142857

## Algorithm

Step 1 – START
Step 2 – Declare 2 double variables area and radius
Step 3 – Read the value of the radius from the user
Step 4- Calculate the area of the circle by using the formula (22*radius*radius)/7 and store
the result as area
Step 5- Display the area value
Step 6 – STOP

## Example 1

Here, the input is being entered by the user based on a prompt. You can try this example live in ourcoding ground tool .

import java.util.Scanner;
public class AreaOfCircle{
public static void main(String args[]){
System.out.println("Required packages have been imported");
Scanner my_scanner= new Scanner(System.in);
System.out.println("A Scanner object has been defined ");
System.out.println("Enter the radius of the circle:");
System.out.println("The Area of Circle is: " + area);
}
}

## Output

Required packages have been imported
A Scanner object has been defined
Enter the radius of the circle:
5
The Area of Circle is: 78.57142857142857

## Example 2

Here, the integer has been previously defined, and its value is accessed and displayed on the console.

public class AreaOfCircle{
public static void main(String args[]){
System.out.println("\nThe Area of Circle is: " + area);
}
}

## Output

The radius of the circle is 5.00000000
The Area of Circle is: 78.57142857142857

Updated on: 21-Feb-2022

1K+ Views