logo image

Java program to calculate circle area

Following program shows you how to calculate circle area. In this tutorial will get circle radius from user and calculate area and prints it using following formula Area = PI X r X r

import java.util.Scanner;

public class MathGeometry8 {

	public static void main(String[] args) {

		double circleRadius;

		Scanner in = new Scanner(System.in);

		System.out.println("Please enter the radius of circle:");
		circleRadius = in.nextDouble();

		double areaOfCircle = Math.PI * (circleRadius * circleRadius);
		System.out.println("Area of circle is: " + areaOfCircle);



Please enter the radius of circle:
Area of circle is: 32.169908772759484