/*Calculate Circle Area In Java example*/
//programming789.blogspot.com/
import java.util.Scanner;
public class CalculateCircleArea
{
public static void main(String[] args)
{
float radius = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Please enter radius of a circle:");
radius = sc.nextFloat();
double area = Math.PI * radius * radius;
System.out.println("Area of a circle is :" + area);
}
}
//programming789.blogspot.com/
import java.util.Scanner;
public class CalculateCircleArea
{
public static void main(String[] args)
{
float radius = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Please enter radius of a circle:");
radius = sc.nextFloat();
double area = Math.PI * radius * radius;
System.out.println("Area of a circle is :" + area);
}
}
Math.PI returns the pi value of 3.141592653589793.
● Save the file as SimpleInterest.java
● When the program is run, the following output is displayed:
Output
Please enter radius of a circle:
12
Area of a circle is :452.3893421169302
Please enter radius of a circle:
12
Area of a circle is :452.3893421169302