CBSE BOARD X, asked by deva1805, 9 months ago

Design a class to overload a function area() as follows:
a. double area(double r, double h)- with radius r as and height h, returns the area of a cylinder using the formula.
A= 2*π*r*h + 2*π*r*r
b. double area(double r)- with radius r , returns the area of a sphere using the formula.
A= 4*π*r*r
c. double area(double l, double b, double h)- with length l, breadth b, and height h returns the area of a cuboid using the formula.
A=2(lb+bh+hl)

Answers

Answered by gamerfreefire8030
1

Answer:

import java.util.Scanner;

public class KboatOverload

{

double area(double a, double b, double c) {

double s = (a + b + c) / 2;

double x = s * (s-a) * (s-b) * (s-c);

double result = Math.sqrt(x);

return result;

}

double area (int a, int b, int height) {

double result = (1.0 / 2.0) * height * (a + b);

return result;

}

double area (double diagonal1, double diagonal2) {

double result = 1.0 / 2.0 * diagonal1 * diagonal2;

return result;

}

}

Explanation:

sorry answer is wrong I tapped wrongly

Similar questions