Task: Java Program to Calculate Area of Circle
What is the formula for calculating Area of Circle?
The required formula for calculating area of circle is:
area = π . r2
Where r is the radius of the circle and π is a mathematical constant with fixed value 3.1415.
We should declare a constant for pi in this Java program, it will enhance program readability and clarity. Here is a detailed explaination on How to Declare a Constant in Java Programs With Examples.
The source code of the Java program to input radius and find area of circle
The output of Java Program to calculate area of circle
Enter radius of circle=5
Area of Circle=78.53750000000001BUILD SUCCESSFUL (total time: 21 seconds)
2,210 total views, 3 views today