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

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

Add two numbers in Scala - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

Goal Parser Interpretation LeetCode Solution - The Coding Shala

Check If N and Its Double Exist in an array - The Coding Shala