### Java Program to find Perimeter of a Circle

The Mathematical equation to find Perimeter or Circumference of a Circle is

In this tutorial we will learn how to calculate Perimeter(Circumference) of a Circle using java program. To write this program we are using predefined classes like Math, Scanner or BufferedReader. BufferedReader used to read the value of radius at runtime or from console.

Here

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Here the Program to calculate area and circumference of circle with user interaction. User will be prompt to enter the radius and the result will be calculated based on the provided radius value.

Also find the program to calculate Area of a Cirlce.

**C=2πr**. We can write hte above equation in our program as**2*Math.PI*r**Here

*double java.lang.Math.PI = 3.141592653589793*The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Here the Program to calculate area and circumference of circle with user interaction. User will be prompt to enter the radius and the result will be calculated based on the provided radius value.

//program to find Perimeter of a Circle package com.javabynataraj; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class PerimeterOfCircle { public static void main(String[] args) { int radius = 0; double peri; //Read the radius of a circle from Console System.out.print("Please enter radius of a circle: "); try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); radius = Integer.parseInt(br.readLine()); } // if any invalid value entered catch (NumberFormatException ne) { System.out.println("Invalid radius value :" + "" + ne); System.exit(0); } catch (IOException ioe) { System.out.println("IO Error :" + ioe); System.exit(0); } peri = 2*Math.PI * radius; System.out.println("Perimeter of a circle is: " + peri); } }Save your java program as

*PerimeterOfCircle.java*in your drive and compile the program using**javac -d . PerimeterOfCircle.java**

**Output:**Also find the program to calculate Area of a Cirlce.

**Reference Books:**- Head First Java (English) 2 Edition
- Head First Servlets And JSP
- Java - The Complete Reference (English) 7th Edition
- HEAD FIRST JAVASCRIPT PROGRAMMING