Java Program to find Area of Geometric Figures using Method Overloading

Write a Java program to find area of geometric figures using method overloading with an example. In this Java example, we will find the area of Square, Rectangle, Triangle, and circle using method overloading.

package NumPrograms;
public class GeometricMethodOverloading 
{
	void calcArea(float a)			
	{
		float area = a * a;
		System.out.println("The Area of a Square    = " + area + " Sq Units");
	}
	
	void calcArea(float a, float b)	
	{
		float area = a * b;
		System.out.println("The Area of a Rectangle = " + area + " Sq Units");
	}	
	
	void calcArea(double r)			
	{
		double area = 3.14 * r * r;
		System.out.println("The Area of a Circle    = " + area + " Sq Units");
	}	
	
	void calcArea(double a, double b)
	{
		double area = (a * b) / 2;
		System.out.println("The Area of a Triangle  = " + area);
	}
	
	public static void main(String[] args) 
	{
		GeometricMethodOverloading obj = new GeometricMethodOverloading();
		
		obj.calcArea(10.6f);
		
		obj.calcArea(14.3f, 22.5f);
		
		obj.calcArea(11.67);
		
		obj.calcArea(18.0, 25.4);
	}
}
Java Program to find Area of Geometric Figures using Method Overloading