Area = pi * r * r
Enter the radius of the circle as an input. Now we use the given formula to calculate the area of the circle.
Here is the source code of the Java Program to Find the Area of a Circle Given the Radius. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Circle
public static void main(String args)
double pi = 3.14, area;
Scanner s = new Scanner(System.in);
System.out.print("Enter radius of circle:");
r = s.nextInt();
area = pi * r * r;
System.out.println("Area of circle:"+area);
$ javac Circle.java $ java Circle Enter radius of circle:22 Area of circle:1519.76
Sanfoundry Global Education & Learning Series – 1000 Java Programs.