India's Largest Free Online Education Platform

Java program to calculate the area of a circle

Java program to calculate the area of a circle

Code:

import static java.lang.System.out;
public class AreaOfCircle
{
    public static void main(String args[])
    {
        float radius=5;
        double area = (3.14) * radius*radius;  // can't use (22/7) bcz it will take int truncated value
        out.println("The area of the cirle having radius:"+radius+ " is: "+area);
    }
}

 

Output:

Leave a Reply

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

error: Content is protected !!