QuestionAsk Questions?

Find the area of Circle in Java.

View Answers

April 16, 2008 at 7:24 PM

Hi,

import java.io.*;

public class CircleArea{

public static void main(String[] args){

try{

BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter Radius of Circle : ");

int r = Integer.parseInt(br1.readLine());

double area = java.lang.Math.PI*r*r;

System.out.println("Area of Circle : "+area);

double perimeter =2*java.lang.Math.PI*r ;

System.out.println("Perimeter of Circle : "+perimeter);

}

catch(Exception e){

System.out.println("Error : "+e);

}

}

}

------------------------

import java.io.*;

public class CircleArea{

public static void main(String[] args){

try{

BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter Radius of Circle : ");

int r = Integer.parseInt(br1.readLine());

double area = java.lang.Math.PI*r*r;

System.out.println("Area of Circle : "+area);

double perimeter =2*java.lang.Math.PI*r ;

System.out.println("Perimeter of Circle : "+perimeter);

}

catch(Exception e){

System.out.println("Error : "+e);

}

}

}

------------------------

Related Tutorials/Questions & Answers: