Miscellaneous
Java Program to Calculate Area of Circle
A Java program to calculate the Area of a Circle.
Problem Description
Write a Java program to calculate the Area of a Circle.
Code
public class AreaOfCircle {
public static void main(String[] args) {
int radius = 3;
double area = Math.PI * radius * radius;
System.out.println("The area of the circle is: " + area);
}
}Output
The area of the circle is: 28.274333882308138Explanation
- Formula:
PI * r * r. - Math.PI: Use the built-in constant for PI.
