yo guys
so uh
I need help
im in 9th grade
and like
this is for my dads work
I wrote the code right
I just dont know how to get the output
6) Write a program to define a class overload with the three member function name “volume”-
i) void volume(int s) – to calculate volume of a cube. [Formula of cube: sss]
ii) void volume(int l, int b, int h) – to calculate volume of a cuboid. [Formula of cuboid: lbh]
iii) void volume(double r) – to calculate volume of a sphere. [Formula of sphere: 4 3 ∏𝑟 3 ]
class Volume {
void volume(int s) {
System.out.println("Volume of cube: " + (s * s * s));
}
void volume(int l, int b, int h) {
System.out.println("Volume of cuboid: " + (l * b * h));
}
void volume(double r) {
System.out.println("Volume of sphere: " + (4.0 / 3.0) * Math.PI * Math.pow(r, 3));
}
}
public class VolumeTest {
public static void main(String[] args) {
Volume v = new Volume();
v.volume(3); // cube
v.volume(3, 4, 5); // cuboid
v.volume(5.0); // sphere
}
}
this is 10th grade stuff
so Im really confused
someone tell me how this works