**Java cone: **In the previous article, we have seen Java Program to Calculate Volume of Dodecahedron

In this article we are going to see how to find the volume and surface area of Frustum of Cone using Java programming language.

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

Before Jumping into the program directly let’s see how we can find the volume and surface area of Frustum of Cone.

**Explanation:**

The frustum of a cone is the part of the cone without vertex when the cone is divided into two parts with a plane that is parallel to the base of the cone. Another name for the frustum of a cone is a truncated cone. Just like any other 3D shape, the frustum of a cone also has surface area and volume. Volume (V) = 1/3 * pi * h * (r*r + R*R + r*R) Curved Surface Area (CSA) = pi * l * (R + r) Total Surface Area (TSA) = pi * l * (R + r) + pi * (R*R + r*r)

Where

- r = radius of smaller circle
- R = radius of bigger circle (or radius of base of the cone)
- h = height of the frustum
- l = slant height of the frustum

**Example: **

Let r = 2 R = 4 h = 5 l = 3 pi = 3.14 Volume (V) = 1/3 * pi * h(r*r + R*R + r*R) => 1/3 * 3.14 * 5*(2*2 + 4*4 + 2*4) = 146.53 Curved Surface Area (CSA) = pi * l(R + r) => 3.14 * 3*(4 + 2) = 56.52 Total Surface Area (TSA) = pi * l(R + r) + pi(R*R + r*r) => 3.14 * 3*(4 + 2) + 3.14*(4*4 + 2*2) = 119.32

Let’s see different ways to find volume and surface area of Frustum of Cone.

### Method-1: Java Program to Find Volume and Surface Area of Frustum of Cone By Using Static Value

**Approach:**

- Declare an double variable say ‘
`R`

’ and assign the value to it, which holds the value of radius of the base of the Cone. (bigger circle) - Declare an double variable say ‘
`r`

’ and assign the value to it, which holds the value of radius of the smaller circle of the frustum. - Declare an double variable say ‘
`h`

’ and assign the value to it, which holds the value of height of the frustum. - Declare an double variable say ‘
`l`

’ and assign the value to it, which holds the value of slant height of the frustum. - Declare a double variable say ‘
`pi`

’ and assign the value as 3.14 - Find the Volume (VOL) of the frustum using the formula
`1/3 * pi * h * (r*r + R*R + r*R)`

- Find Curved Surface Area (CSA) of the frustum using the formula
`pi * l * (R + r)`

- Find Total Surface Area (TSA) of the frustum using the formula
`pi * l * (R + r) + pi * (R*R + r*r)`

- Print the result.

**Program:**

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

### Method-2: Java Program to Find Volume and Surface Area of Frustum of Cone By Using User Input Value

**Approach:**

- Declare an double variable say ‘
`R`

’ which holds the value of radius of the base of the Cone. (bigger circle) - Declare an double variable say ‘
`r`

’ which holds the value of radius of the smaller circle of the frustum. - Declare an double variable say ‘
`h`

’ which holds the value of height of the frustum. - Declare an double variable say ‘
`l`

’ which holds the value of slant height of the frustum. - Take input of values for
`R`

,`r`

,`h`

,`l`

by using Scanner class. - Declare a double variable say ‘
`pi`

’ and assign the value as 3.14 - Find the Volume (VOL) of the frustum using the formula
`1/3 * pi * h * (r*r + R*R + r*R)`

- Find Curved Surface Area (CSA) of the frustum using the formula
`pi * l * (R + r)`

- Find Total Surface Area (TSA) of the frustum using the formula
`pi * l * (R + r) + pi * (R*R + r*r)`

- Print the result.

**Program:**

import java.util.*; class Main { public static void main(String [] args) { //Scanner class object created Scanner s = new Scanner(System.in); System.out.println("Enter the bigger radius of frustum:"); double R = s.nextDouble(); System.out.println("Enter the smaller radius of frustum:"); double r = s.nextDouble(); System.out.println("Enter the height of frustum:"); double h = s.nextDouble(); System.out.println("Enter the slant height of frustum:"); double l = s.nextDouble(); //pi value declared double pi = 3.141; // 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: Enter the bigger radius of frustum: 8 Enter the smaller radius of frustum: 4 Enter the height of frustum: 13 Enter the slant height of frustum: 14 The volume of Frustum of Cone is:1524.432 The CSA of Frustum of Cone is:527.6880000000001 The TSA of Frustum of Cone is:778.9680000000001

Don’t stop learning now. Get hold of all the important Java fundamentals with the Simple java program example guide and practice well.

**Related Java Articles:**