In the Following example PerimeterofCircleExample shows how to Calculate Perimeter of Circle using 2*pi*r. where r is a radius of a circle.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PerimeterofCircleExample { // Declaring class name as PerimeterofCircleExample
public static void main(String[] args) {
int r = 0; // r for radius of circle
System.out.print("Please enter the radius value r :");
try
{
//Obtaining the keyboard input with BufferedReader
BufferedReader Buffer= new BufferedReader(new InputStreamReader(System.in));
r = Integer.parseInt(Buffer.readLine());
/* Math.PI = 3.14 is Math constant to get value of pi
Perform Calculations and Display Result
calculate the perimeter of circle that is PerimeterofCircle = 2 *pi*r
*/
double PerimeterofCircle = 2 * Math.PI * r;
System.out.println("The Perimeter of circle is " + PerimeterofCircle);
}
catch(Exception e)
{
System.out.println("Input Error : "+e);
}
}
}