Java Program to Find the Area of Circle - The Coding Shala

Home >> Java Programs >> Area of Circle

 In this post, we will learn how to write a Java Program to Find the Area of Circle.

Java Program to Find the Area of Circle

The radius of the circle is given, find the area of the circle using the Java program.

Area of Circle = Pi * (radius * radius)

Example 1:
Input: radius = 3
Output: Area = 28.274333882308138

Java Program: 

// Java program to Find Area of Circle

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		
		// take radius input
		System.out.println("Enter the radius of circle");
		double radius = sc.nextDouble();
		
		// calculate the area
		// area = Pi * (radius * radius)
		double area = Math.PI * (radius * radius);
		System.out.println("Area of Circle is: " + area);
		
		sc.close();
	}
}

Output: 

Enter the radius of circle
3
Area of Circle is: 28.274333882308138


Other Posts You May Like
Please leave a comment below if you like this post or found some errors, it will help me to improve my content.

Comments

Popular Posts from this Blog

Anti Diagonals - The Coding Shala

Shell Script to find sum, product and average of given numbers - The Coding Shala

LeetCode - Bulb Switcher Solution - The Coding Shala

New Year Chaos Solution - The Coding Shala

Sorting the Sentence LeetCode Solution - The Coding Shala