Computer Science, asked by divv06, 3 days ago

Write a program in Java:
Design a class to overload a function volume( ) as follows:

double volume(double r) — with radius (r) as an argument, returns the volume of sphere using the formula:
V = (4/3) * (22/7) * r * r * r
double volume(double h, double r) — with height(h) and radius(r) as the arguments, returns the volume of a cylinder using the formula:
V = (22/7) * r * r * h
double volume(double 1, double b, double h) — with length(l), breadth(b) and height(h) as the arguments, returns the volume of a cuboid using the formula:
V = l*b*h ⇒ (length * breadth * height)

Plz answer guys.

Answers

Answered by believeyourself
2

Answer:

ANSWER

public class KboatVolume

{

double volume(double r) {

double vol = (4 / 3.0) * (22 / 7.0) * r * r * r;

return vol;

}

double volume(double h, double r) {

double vol = (22 / 7.0) * r * r * h;

return vol;

}

double volume(double l, double b, double h) {

double vol = l * b * h;

return vol;

}

public static void main(String args[]) {

KboatVolume obj = new KboatVolume();

System.out.println("Sphere Volume = " +

obj.volume(6));

System.out.println("Cylinder Volume = " +

obj.volume(5, 3.5));

System.out.println("Cuboid Volume = " +

obj.volume(7.5, 3.5, 2));

Answered by prachijha506
1

Answer:

hope this helps you

Explanation:

hope this helps you

please mark me as brainliest please

Attachments:
Similar questions