Calculate Circle Area using Java Example
Previous | Home | Next |
Calculate Circle Area using Java Example
//program for calculate Area and circumference of a circle.
package r4r.co.in;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class NewClass {
public static void main(String[] args) throws IOException {
BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Radius of circle:");
String s = d.readLine();
int n1 = Integer.parseInt(s);
//Code for Circle
float a = (float) (3.14 * n1 * n1);
System.out.println("Area of the circle:" + a);
float b = (float) (2 * 3.14 * n1);
System.out.println("circumference of a circle:" + b);
}
}
Enter the Radius of circle:
10
Area of the circle:314.0
circumference of a circle:62.8
Previous | Home | Next |