write a program with the name area using function overloading that computes the area of parallelogram, rhombus and trapezium in java
Answers
Answered by
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
Social Sciences,
2 months ago
India Languages,
2 months ago
History,
10 months ago
English,
10 months ago
Science,
10 months ago