- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Java Program to Find the Surface area and Volume of Cuboid

In this article, we will understand how to compute the surface area and volume the cuboid. Cuboid is a three-dimensional object with six faces of rectangle shape which means it has sides of different length and breadth. The difference between a cube and cuboid is that a cube has equal length, height and breadth whereas in cuboids these three are not same

The surface area of cuboid is calculated using the formula −

2*( length *width + width* height + height*length)

The area of the cuboid is calculated using the formula −

length*width*height

Below is a demonstration of the same −

**Input**

Suppose our input is −

Length= 6; Width= 7; Height= 8;

**Output**

The desired output would be −

Volume Of the Cuboid is : 336.0 Surface area Of the Cuboid is : 292.0

## Algorithm

Step 1 - START Step 2 - Declare five double values namely my_length, my_width, my_height, my_volume, my_surface_area Step 3 - Read the required values from the user/ define the values Step 4 - Use the formula 2*( length *width + width* height + height*length) to calculate the surface area of cuboid Step 5 - Use the formula length*width*height to calculate the area of the cuboid Step 6 - Display the result Step 7 - Stop

## Example 1

Here, the input is being entered by the user based on a prompt. You can try this example live in ourcoding ground tool .

import java.util.Scanner; public class VolumeOfCuboid{ public static void main(String args[]){ double my_length, my_width, my_height, my_volume, my_surface_area; System.out.println("Required packages have been imported"); Scanner my_scanner = new Scanner(System.in); System.out.println("A reader object has been defined "); System.out.println("Enter the length of Cubiod:"); my_length=my_scanner.nextDouble(); System.out.println("Enter the width of Cubiod:"); my_width=my_scanner.nextDouble(); System.out.println("Enter height of Cubiod:"); my_height=my_scanner.nextDouble(); my_volume= my_length*my_width*my_height; System.out.println("The volume Of the Cuboid is :" +my_volume); my_surface_area =2*( my_length *my_width + my_width* my_height + my_height*my_length); System.out.println("The surface area Of the Cuboid is : " +my_surface_area); } }

## Output

Required packages have been imported A reader object has been defined Enter the length of Cubiod: 6 Enter the width of Cubiod: 7 Enter height of Cubiod: 8 The volume Of the Cuboid is : 336.0 The surface area Of the Cuboid is : 292.0

## Example 2

Here, the integer has been previously defined, and its value is accessed and displayed on the console.

public class VolumeOfCuboid{ public static void main(String args[]){ double my_length, my_width, my_height, my_volume, my_surface_area; my_length= 6; my_width= 7; my_height= 8; my_volume= my_length*my_width*my_height; System.out.println("The volume Of the Cuboid is:" +my_volume); my_surface_area =2*( my_length *my_width + my_width* my_height + my_height*my_length); System.out.println("The surface area Of the Cuboid is:" +my_surface_area); } }

## Output

The volume Of the Cuboid is:336.0 The surface area Of the Cuboid is:292.0

- Related Articles
- Swift Program to Find the Surface area and Volume of Cuboid
- Haskell Program to Find the Surface area and Volume of Cuboid
- Kotlin Program to Find the Surface Area and Volume of Cuboid
- Program for Volume and Surface Area of Cuboid in C++
- How to find the Surface area and Volume of Cuboid in Golang?
- Golang program to Calculate the Volume, Diagonal and Area of a Cuboid?
- Two cubes each of volume $27 m^{3}$ are joined end to end. Find the surface area of the resulting cuboid.
- Two cubes each of volume $64 cm^3$ are joined end to end. Find the surface area of the resulting cuboid.
- Two cubes, each of volume $512 cm^3$ are joined end to end. Find the surface area of the resulting cuboid.
- 2 cubes each of volume $64 cm^3$ are joined end to end. Find the surface area of the resulting cuboid."
- Program for Volume and Surface Area of Cube in C++
- Find maximum volume of a cuboid from the given perimeter and area in C++
- What is total surface area of cuboid?
- How to find Volume and Surface Area of a Sphere using C#?
- Find the lateral surface area and total surface area of a cuboid of length $80 cm$, breadth $40 cm$ and height $20 cm$.