In this post, we will learn to code the **Java Program to Calculate Circumference of a Circle.** Let’s understand about Circle and the formula to calculate the circumference of a given circle. Then we will learn **How to Calculate the Circumference of a Circle in Java Programming Language.**

A **Circle** is defined as the set of points placed at an equal distance from a fixed point in a plane called a **center.**

**Circumference of a Circle**

The formula to calculate the circumference of a circle is as follows,

**Circumference of a Circle, C = 2 * Ï€ * r**, where,

**(pie) is equal to the fraction**

**Ï€****22/7**and

**r**stands for

**radius**.

Now, let’s see theJava Program to Calculate Circumference of a Circle

**Java Program to Calculate Circumference of a Circle**

import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println("Enter the radius of the circle : "); float radius = sc.nextFloat(); float circumference = (22.0f/7.0f) * radius * 2; System.out.println("Circumference of the Circle is "+ circumference +" units"); } }

**Output**

`Enter the radius of the circle : `**25**
**Circumference of the Circle is 157.14285 unit**
Enter the radius of the circle : **7**
**Circumference of the Circle is 44.0 units**

**How Does This Program Work ?**

**How Does This Program Work ?**

Scanner sc = new Scanner(System.in); System.out.println("Enter the radius of the circle : "); float radius = sc.nextFloat();

In this program, we have taken the input of the radius from the user and stored it in the variable **radius** of datatype **float** using the Scanner Class in Java.

float circumference = (22.0f/7.0f) * radius * 2;

Then, we calculated the circumference of the circle using the formula, i.e. **Circumference of a Circle, C = 2 * Ï€ * r**, where,

**(pie) is equal to the fraction**

**Ï€****22/7**and

**r**stands for

**radius**and we stored it in the variable named

**circumference**of

**float**datatype because

**pie**is a decimal value.

System.out.println("Circumference of the Circle is "+ circumference +" units");

Then, we printed the result using the

function to print in Java. This is the **System.out.println()****Java Program to Calculate Circumference of a Circle.**

*Read more : Java Program to Calculate the Area of a Circle*

**Conclusion**

I hope after going through this post, you understand how to code **Java Program to Calculate Circumference of a Circle.**

If you have any doubt regarding the topic, feel free to contact us in the Comment Section. We will be delighted to help you.

**Also Read:**