Java Program to find Diameter, Circumference, and Area of a Circle

Write a Java Program to find the Diameter, Circumference, and Area of a circle with an example. This example allows entering the circle radius and finding the diameter, area, and circumference using a math formula.

  • Diameter of a Circle = 2 * radius
  • Area of a Circle = π * radius2
  • Circumference of a Circle = 2 * π * radius
package Area;

import java.util.Scanner;

public class DCAOfCricle1 {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);	
		double radius, diameter, area, circumference;	

		System.out.print("Please Enter the Circle radius = ");
		radius = sc.nextDouble();	
	
		diameter = 2 * radius;
		area = Math.PI * radius * radius; 
		circumference = 2 * Math.PI * radius;

		System.out.println("\nArea of a Circle        = " + area);
		System.out.println("Diameter of a Circle      = " + diameter);
		System.out.println("Circumference of a Circle = " + circumference);
	}
}
Java Program to find Diameter, Circumference, and Area of a Circle

Java Program to find Diameter, Circumference, and Area of a Circle

This program declared a calcDiameter, calcArea, and calCircumference functions that return the Circle Diameter, Circumference, and Area.

package Area;

import java.util.Scanner;

public class DCAOfCricle2 {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		double radius, diameter, area, circumference;
		
		System.out.print("Please Enter the Circle radius = ");
		radius = sc.nextDouble();
		
		diameter = calcDiameter(radius);
		area = calcArea(radius); 
		circumference = calCircumference(radius);

		System.out.println("\nArea of a Circle        = " + area);
		System.out.println("Diameter of a Circle      = " + diameter);
		System.out.println("Circumference of a Circle = " + circumference);
	}
	
	public static double calcDiameter(double radius) {
		return 2 * radius;
	}
	public static double calcArea(double radius) {
		return Math.PI * radius * radius;
	}
	public static double calCircumference(double radius) {
		return 2 * Math.PI * radius;
	}
}
Please Enter the Circle radius = 12

Area of a Circle        = 452.3893421169302
Diameter of a Circle      = 24.0
Circumference of a Circle = 75.39822368615503