Java program to calculate Area and Circumference of a Circle

Views: 244   

A simple Java program to calculate Area and Circumference of a Circle by taking radius as input

import java.util.Scanner;

public class AreaAndCircumferenceOfCircle {

    public static void main(String args[]) {
        System.out.print("Enter the Radius: ");
        Scanner sc = new Scanner(System.in);
        double radius = sc.nextDouble();
        sc.close();

        double area = Math.PI * (radius * radius);
        System.out.println("The Area of circle is: " + area);

        double circumference = Math.PI * 2 * radius;
        System.out.println("The Circumference of the circle is:" + circumference);
    }

}

Output

Enter the Radius: 12
The Area of circle is: 452.3893421169302
The Circumference of the circle is:75.39822368615503
On By