Simple Area & Perimeter of Circle Program in JAVA.

  1. import java.io.*;  
  2. import java.lang.*;  
  3. class CircleArea{  
  4.     public static void main(String[] args){  
  5.         int r=0;  
  6.             try{  
  7.                 BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));  
  8.                 System.out.println("Enter Radius of Circle  : ");  
  9.                 r = Integer.parseInt(br1.readLine());  
  10.                 double area = Math.PI*r*r;  
  11.                 System.out.println("Area of Circle : "+area);  
  12.                 double  perimeter =2*Math.PI*r ;  
  13.                 System.out.println("Perimeter of Circle : "+perimeter);  
  14.             }  
  15.             catch(Exception e){  
  16.                 System.out.println("Error : "+e);  
  17.             }          
  18.     }