java program to calculate area and circumference of circle using class code example
Example 1: Java program to calculate area of a circle
import java.util.Scanner;
public class CalculateAreaOfCircle
{
public static void main(String[] args)
{
double radius;
double pi = 3.1415, area;
Scanner sc = new Scanner(System.in);
System.out.println("Please enter radius of circle: ");
radius = sc.nextDouble();
area = pi * radius * radius;
System.out.println("Area of circle: " + area);
sc.close();
}
}
Example 2: how to find circumference of a circle
curcomfrance = pi * radius * 2