Saturday, October 18, 2025
HomeLanguagesJavaJava Program to Calculate and Display Area of a Circle

Java Program to Calculate and Display Area of a Circle

Given a radius of the circle, write a java program to calculate and display the area of the circle. (Take ∏=3.142)

Example

Input : radius= 5
Output: Area of circle is : 78.55

Input : radius= 8
Output: Area of circle is : 201.08

As we know to calculate the area of a circle, the radius of the circle must be known, so if the radius of the circle is known, then the area of the circle can be calculated by using the formula:

Area = 3.142*(radius)*(radius)

Below is the Java Program to calculate the area of the circle:- 

Java




// Java program to calculate the area of the
public class GFG {
    public static void main(String[] args)
    {
        int radius;
        double pi = 3.142, area;
        radius = 5;
        // calculating the area of the circle
        area = pi * radius * radius;
        // printing the area of the circle
        System.out.println("Area of circle is :" + area);
    }
}


Output

Area of circle is :78.55

Time complexity: O(1) since performing constant operations

Auxiliary Space: O(1)

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS