Please login


Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Java Program for calculating the Area of a circle

Area of a circle using Java :

The area of a circle is the number of square units inside the circle. If we know the radius of the circle, then we can directly calculate the area by using a standard formula, 

A = π * (radius * radius)

where, A is the Area enclosed by a circle, 

π is a constant with value 3.14, and 

r is the radius of the circle.

In this article, we will create a java program to calculate the area of a circle, where radius is asked to be entered by the user.



Step 1 : Ask the user to enter the radius of a circle.

Step 2 : Calculate the area of a circle by using the standard formula:

A = π * (radius * radius)

Step 3 : Print the result.

Java Code:-

//Java program to calculate area of a circle
import java.util.Scanner;
public class area_of_circle
	public static void main(String[] args)
		//scanner class declaration
		Scanner sc = new Scanner(;
               //input from the user
		System.out.print("Enter the radius of a circle : ");		
		double radius = sc.nextFloat();			
              //formula for area of a circle
		double area = 3.14 * radius * radius;		
             //closing scanner class(not compulsory, but good practice)
Enter the radius of a circle : 12
Enter the radius of a circle : 4