write a program with the name area using function overloading that computes the area of parallelogram, rhombus and trapezium in java
Answers
Answer:
Transpiration is the process of water movement through a plant and its evaporation from aerial parts, such as leaves, stems and flowers. Water is necessary for plants but only a small amount of water taken up by the roots is used for growth and metabolism. The remaining 97–99.5% is lost by transpiration and guttation.
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: "+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);
}
}