# 4 – Simple and easy Java program to calculate area

## Java program to calculate area

Area is a space occupied by any flat surface. Following java program will calculate and return area of circle, square, rectangle and triangle.

### Program to calculate area in Java

`//always check name of classimport java.util.*;//itvoyagers.inclass Area{    float a;    public void area_Circle(float r)    {        a = r*r*3.14f;        System.out.println("nArea of Circle is : "+a);    }    public void area_Square(float s)    {        a = s*s;        System.out.println("nArea of Square is : "+a);    }//itvoyagers.in    public void area_Rectangle(float l, float b)    {        a = l*b;        System.out.println("nArea of Rectangle is : "+a);    }    public void area_Triangle(float b, float h)    {        a = b*h;        System.out.println("nArea of Triangle is : "+a);    }}//itvoyagers.inclass FindArea{    public static void main(String agr[])    {        float radius,side,length,breadth,base,height;        Scanner in = new Scanner(System.in);//you can accept values from user        radius = 6;        side = 10;        length = 5;        breadth = 12;        base = 8;        height = 7;        Area area = new Area();        area.area_Circle(radius);        area.area_Square(side);        area.area_Rectangle(length,breadth);        area.area_Triangle(base,height);    }}`

Output :

Area of Circle is : 113.04

Area of Square is : 100.0

Area of Rectangle is : 60.0

Area of Triangle is : 56.0

### Connect with us on following platforms

We are aiming to explain all concepts of Java in easiest terms as possible. ITVoyagers
Author