Computer Science, asked by richamishra207, 5 months ago

write a program with the name area using function overloading that computes the area of parallelogram, rhombus and trapezium in java​

Answers

Answered by anindyaadhikari13
2

Question:-

➡Write a class with the name area using function overloading that computes the area of parallelogram, rhombus and trapezium in java.

Program:-

import java.util.*;

class Area

{

void area(int base, int height)

{

double a=0.5*base*height;

System.out.println("Area of the Parallelogram is: k "+a);

}

void area(double d1, double d2)

{

double a=0.5*d1*d2;

System.out.println("Area of the Rhombus is: "+a);

}

void area(double h, double a, double b)

{

double A=0.5*h*(a+b);

System.out.println("Area of the trapezium is: "+A);

}

public static void main(String args[])

{

Area obj=new Area();

obj.area(2,3);

obj.area(20.0,50.0);

obj.area(10.0,20.0,20.0);

}

}

Similar questions