Monday, July 16, 2012

Write a program to calculate area and perimeter of a circle in Java

0 comments
Write a program to calculate area and perimeter of a circle in Java.

Here is the code of the program:
import java.io.*;
class RecArea
{
public static void main(String[] args)
{

int l=0;
int w=0;

try{

BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter length of rectangle : ");
l = Integer.parseInt(br1.readLine());
System.out.println("Enter width of rectangle : ");
w = Integer.parseInt(br1.readLine());
int area = l*w;
System.out.println("Area of Rectangle : "+area);
int perimiter = 2*(l+w);
System.out.println("Perimeter: " + perimiter);

}catch(Exception e){System.out.println("Error : "+e);}

}
}
Download this example.

0 comments:

Post a Comment