0% found this document useful (0 votes)
89 views1 page

4 Jav

Uploaded by

royaldecor051
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views1 page

4 Jav

Uploaded by

royaldecor051
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

public class AreaCalculator {

public double calculateArea(double radius) {


return Math.PI * radius * radius;
}

public double calculateArea(double length, double width) {


return length * width;
}

public double calculateArea(double base, double height, boolean isTriangle) {


return 0.5 * base * height;
}

public static void main(String[] args) {


AreaCalculator areaCalculator = new AreaCalculator();

double circleArea = areaCalculator.calculateArea(5);


double rectangleArea = areaCalculator.calculateArea(10, 5);
double triangleArea = areaCalculator.calculateArea(8, 6, true);

System.out.println("Area of Circle: " + circleArea);


System.out.println("Area of Rectangle: " + rectangleArea);
System.out.println("Area of Triangle: " + triangleArea);
}
}

Output

Area of Circle: 78.53981633974483


Area of Rectangle: 50.0
Area of Triangle: 24.0

You might also like