Java Program to find area of Geometric figures using method Overloading.

class JavaExample
{
    void calculateArea(float x)
    {
        System.out.println("Area of the square: "+x*x+" sq units");
    }
    void calculateArea(float x, float y)
    {
        System.out.println("Area of the rectangle: "+x*y+" sq units");
    }
    void calculateArea(double r)
    {
        double area = 3.14*r*r;
        System.out.println("Area of the circle: "+area+" sq units");
    }
    public static void main(String args[]){
        JavaExample obj = new JavaExample();
       
        
  obj.calculateArea(6.1f);
    
 
  obj.calculateArea(10,22);
    
 
  obj.calculateArea(6.1);
    }
}
Java Program to find area of Geometric figures using method Overloading. Java Program to find area of Geometric figures using method Overloading. Reviewed by on December 20, 2019 Rating: 5

No comments:

Powered by Blogger.