Program to calculate area of circle

Program to calculate area of circle

Program to calculate area of circle

This is a Java Program to Calculate and Display Area of a Circle.
Formula:
Area of circle=pi * r * r
Enter the radius of the circle as input.

Now we use the given formula to calculate the area of the circle using formula.

import java.util.Scanner;
public class Area
{
public static void main(String[] args) 
    {
int r;
double pi = 3.14, area;
        Scanner s = new Scanner(System.in);
System.out.print("Enter radius of circle:");
        r = s.nextInt();
area = pi * r * r;
System.out.println("Area of circle:"+area);
    }            
}

Program Output:

$ javac Area.java
$ java Area

Enter radius of circle:24
Area of circle:1808.63999

I hope this post helps you to understand Area of circle and its implementation in Java programming language.

Keep coding 🙂

2 thoughts on “Program to calculate area of circle”

Leave a Reply

Your email address will not be published. Required fields are marked *