Volume of Shapes

Using function overloading calculate volume of cube, cuboid and sphere.

Volume of Cube = side3

Volume of Sphere = (4/3)*π*r3

Volume of Cuboid = length*breadth*height

Take all required inputs from main functions and invoke the function which calculates volume using class object.

Java
import java.util.*;
public class Compute
{
    double v=0.0;
    public void getVolume(int s)
    {
        v=s*s*s;
        System.out.println("Volume of cube: "+v);
    }
    public void getVolume(double r)
    {
        v=(4/3)*(22/7)*r*r*r;
        System.out.println("Volume of sphere: "+v);
    }
    public void getVolume(double l,double b,double h)
    {
        v=l*b*h;
        System.out.println("Volume of cuboid: "+v);
    }
    public static void main(String args[])
    {
        int s=0;
        double r=0.0,l=0.0,b=0.0,h=0.0;
        Scanner sc=new Scanner(System.in);
        Compute ob=new Compute();
        System.out.print("Enter side of cube: ");
        s=sc.nextInt();
        System.out.print("Enter radius of sphere: ");
        r=sc.nextDouble();
        System.out.print("Enter length of cuboid: ");
        l=sc.nextDouble();
        System.out.print("Enter breadth of cuboid: ");
        b=sc.nextDouble();
        System.out.print("Enter height of cuboid: ");
        h=sc.nextDouble();
        ob.getVolume(s);
        ob.getVolume(r);
        ob.getVolume(l,b,h);
    }
}
Java