8+ Java Programs to Calculate Area of a Circle

This post contains a total of 8+ Java Program Examples with Source Code to Calculate the Area of a Circle. All these Circle Area Calculator programs are made using Java.

You can use the source code of these examples with credits to the original owner.

Related Posts

Java Programs to Calculate Area of Circle

1. By Ahmed Mahmoud

Made by Ahmed Mahmoud. Basic Program for calculating area of circle. Source

Enter the ridius in cm please!
10
Area=314.0cm^2
import java.util.Scanner;
public class CircleArea
{
	public static void main(String[] args) {
		double R,A;
  System.out.println("Enter the ridius in cm please!");
  Scanner s = new Scanner(System.in);
  R = s.nextDouble();
  A = R*R*3.14;
  System.out.println("Area="+A+"cm^2" );
  System.out.println("thanks for checking my code");
	}
}

2. By JosΓ© Baltazar Castillo RodrΓ­guez

Made by JosΓ© Baltazar Castillo RodrΓ­guez. Basic Java Program for Calculating Area of a Circle. Source

Enter value of circle radio: 11
The cicle area with radio 11.0 is: 380.132711084365
import java.util.Scanner;

public class Program

{
	public static void main(String[] args) {
	    
	    Scanner sc= new Scanner (System.in);
	    
	    double Area, Radio; 
	    
        System.out.println("Enter value of circle radio: ");        
        Radio= sc.nextDouble();
        
        Area= Math.PI*(Radio*Radio);  
        
        System.out.println("The cicle area with radio " + Radio+ " is: " + Area);
		
	}
}

3. By Takudzwa Nelson Chiutaalenga

Made by Takudzwa Nelson Chiutaalenga. Circle Area and Circumference Calculator. Source

Enter the radius: 12
The area of circle is: 452.3893421169302
The circumference of the circle is:75.39822368615503
import java.util.Scanner; 

class Program { 

    static Scanner sc = new Scanner(System.in);
    
    public static void main(String args[]) {
     
    System.out.print("Enter the radius: "); 
    
    /*We are storing the entered radius in double 
    * because a user can enter radius in decimals 
    */ 
    
    double radius = sc.nextDouble(); 
    
    //Area = PI*radius*radius 
    double area = Math.PI * (radius * radius); System.out.println("The area of circle is: " + area); 
    
    //Circumference = 2*PI*radius 
    double circumference= Math.PI * 2*radius; System.out.println( "The circumference of the circle is:"+circumference) ;
     
    } 
}

4. By Ivy

Made by Ivy. Source

Radius of circle = 13.0
Area = 530.929158456675
Circumference = 81.68140899333463
import java.util.*;
class Circle{
    public double area(double r){
        double a = Math.PI*r*r;
        return a;
    }
    public double circumference(double r){
        double c = 2*Math.PI*r;
        return c;
    }
    public static void main(String args[]){
        double x,y,z;
        Circle obj1 = new Circle();
        Circle obj2 = new Circle();
        Scanner sc = new Scanner(System.in);
        x = sc.nextDouble();
        y = obj1.area(x);
        z = obj2.circumference(x);
        System.out.println("Radius of circle = "+x+"\nArea = "+y+"\nCircumference = "+z);
    }
}

5. By AhmedRamadan

Made by AhmedRamadan. Source

Enter a number for radius 14
The area of the circle of radius 14.0 = 615.75164
import java.util.Scanner ;

public class AreaOfCircle
{
    public static void main(String[] args) {
    final double PI = 3.14159;
    Scanner input = new Scanner (System.in);
    System.out.println("Enter a number for radius");
    
    double radius = input.nextDouble();
    if (radius < 0){
        System.out.println ("Incorrect input");
    }else {
        double area = radius * radius *PI;
        System.out.println("The area of the circle of radius " + radius +" = "+ area);
        }
        
    }
}

6. By Ridha Al Awami

Made by Ridha Al Awami. Source

15
the circumference of the circle is = 94.24777960769379
area of the circle =706.8583470577034
public class Program
{
    public static void main(String[] args) {
        /* More complex operations
        * by using Math class to calculate the circumference and the area of a circle
        * given the radius.
        */
        // r is the radius of the circle
        double r = 15;
        double circleCircumference = 2 * Math.PI * r;
        double circleArea = Math.PI * Math.pow(r,2);
        System.out.println("the circumference of the circle is = " + circleCircumference);
        System.out.println("area of the circle =" + circleArea );
    }
}

7. By Shahida Khanam

Made by Shahida Khanam. Simple Java Program to Find Area of a Circle using Radius Input. Source

write the radius of the circle: 16
the area of the circle is: 804.352
import java.util.Scanner;


public class Program
{
    public static void main(String[] args) {    
    
    
double pi=3.142;
int r;
double result;

Scanner input = new Scanner(System.in);
System.out.println("write the radius of the circle: ");

r = input.nextInt();

result = pi*r*r;
System.out.println(" the area of the circle is: " +result);

        
    }
}

8. By Nil Lumacang

Made by Nil Lumacang. Source

radius of circle = 17
Circle area  =  907.9202768874503
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class CircleArea {
 
        public static void main(String[] args) {
               
                int circle_radius = 0;
               
                try
                {
                        BufferedReader cr = new BufferedReader(new InputStreamReader(System.in));
                        circle_radius = Integer.parseInt(cr.readLine());
                }
              
                catch(NumberFormatException ne)
                {
                        System.out.println("Invalid radius value" + ne);
                        System.exit(0);
                }
                catch(IOException ioe)
                {
                        System.out.println("IO Error :" + ioe);
                        System.exit(0);
                }
               
           
                double area = Math.PI * circle_radius * circle_radius;
                
             System.out.println("radius of circle = " + circle_radius);
               
                System.out.println(" Circle area  =  " + area);
        }
}

9. By Ellapu Keerthi

Made by Ellapu Keerthi. Source

18
area of circle = 1017.36
import java.util.Scanner ;
class circle {
    public static void main (String args [])
    {
     float  r , t;
        Scanner k = new Scanner (System.in) ;
        r=k.nextInt();
        t=3.14f*r*r;
        System.out.println("area of circle = " + t);
    }
}