# Volume formula for dodecahedron – Java Program to Calculate Volume of Dodecahedron

Volume formula for dodecahedron: In the previous article, we have seen Java Program to Check if Two Given Circles Touch or Intersect Each Other

In this article we are going to see how to find the volume of dodecahedron using Java programming language.

## Java Program to Calculate Volume of Dodecahedron

How to find the surface area of a dodecahedron: Before Jumping into the program directly let’s see how we can find the volume of dodecahedron.

Explanation:

In geometry, a dodecahedron or duodecahedron is any polyhedron with twelve flat faces. The most familiar dodecahedron is the regular dodecahedron with regular pentagons as faces.

Number of faces: 12

Number of edges: 30

Number of vertices: 20

Formula to find total volume of dodecahedron = (side*side*side) * (15+7√5)/4

Example:

Let length of one side of dodecahedron be “l” = 5

So, volume of dodecahedron = (side*side*side) * (15+7√5)/4

=> (5*5*5) * (15+7√5)/4 = 957.88

Let’s see different ways to find the volume of dodecahedron.

### Method-1: Java Program to Calculate Volume of Dodecahedron By Using Static Value

Approach:

• Declare an integer variable say ‘l’ and assign the value to it,  which holds the value of one side of the dodecahedron.
• Find the volume of dodecahedron using the formula (side3) * (15+7√5)/4
• Print the result.

Program:

import java.io.*;
class Main
{
public static void main(String [] args)
{
int l = 5;
// formula to find volume of dodecahedron
double volume = (l*l*l)*(15+7*(Math.sqrt(5)))/4;
System.out.println("The volume of dodecahedron is " + volume);
}
}

Output:

The volume of dodecahedron is 957.8898700780791

### Method-2: Java Program to Calculate Volume of Dodecahedron By Using User Input Value

Approach:

• Declare an integer variable say ‘l’ which holds the value of one side of the dodecahedron.
• Take the value of ‘l’ as user input by using Scanner class.
• Find the volume of dodecahedron using the formula (side3) * (15+7√5)/4
• Print the result.

Program:

import java.util.*;
class Main
{
public static void main(String [] args)
{
// scanner class obj ref
Scanner s = new Scanner(System.in);
//Taking the user input of side length value of dodecahedron
System.out.println("Enter the value of the side of the dodecahedron:");
int l = s.nextInt();

// formula to find volume of dodecahedron
double volume = (l*l*l)*(15+7*(Math.sqrt(5)))/4;
System.out.println("The volume of dodecahedron is " + volume);
}
}

Output:

Enter the value of the side of the dodecahedron:
4
The volume of dodecahedron is 490.43961347997646

### Method-3: Java Program to Calculate Volume of Dodecahedron By Using User Defined Method

Approach:

• Declare an integer variable say ‘l’ which holds the value of one side of the dodecahedron.
• Take the value of ‘l’ as user input by using Scanner class.
• Call the user defined method findVol() and pass ‘l’ as parameter.
• Find the volume of dodecahedron using the formula (side3) * (15+7√5)/4
• Print the result.

Program:

import java.util.*;
class Main
{
public static void main(String [] args)
{
// scanner class obj ref
Scanner s = new Scanner(System.in);
//Taking the user input of side length value of dodecahedron
System.out.println("Enter the value of the side of the dodecahedron:");
int l = s.nextInt();
//callling method findVol()
findVol(l);
}

public static void findVol(int l)
{
// formula to find volume of dodecahedron
double volume = (l*l*l)*(15+7*(Math.sqrt(5)))/4;
System.out.println("The volume of dodecahedron is " + volume);
}
}

Output:

Enter the value of the side of the dodecahedron:
2
The volume of dodecahedron is 61.30495168499706

Practice Java programming from home without using any fancy software just by tapping on this Simple Java Programs for Beginners tutorial.

Related Java Articles: