Java Program to Find Volume and Surface Area of Frustum of Cone

bookmark

class Main
{
    public static void main(String [] args)
    {
        double r = 2;
        double R = 4;
        double h = 5;
        double l = 3;
        double pi = 3.14;
        // formula to find vol of Frustum of Cone
        double vol = (pi * h * ((r * r) + (R * R) + (r * R)))/3;
        // formula to find curved surface area of Frustum of Cone
        double csa = pi * l * (R + r); 
        // formula to find total surface area of Frustum of Cone
        double tsa = pi * l * (R + r) + pi * (r * r + R * R); 
        System.out.println("The volume of Frustum of Cone is:" + vol);
        System.out.println("The CSA of Frustum of Cone is:" + csa);
        System.out.println("The TSA of Frustum of Cone is:" + tsa);
    }
}

 


Output:

The volume of Frustum of Cone is:146.53333333333333
The CSA of Frustum of Cone is:56.519999999999996
The TSA of Frustum of Cone is:119.32