이 기사에서는 입방체의 표면적과 부피를 계산하는 방법을 이해할 것입니다. 직육면체는 6개의 면이 있는 직사각형 모양의 3차원 물체로, 변의 길이와 너비가 다릅니다. 정육면체와 직육면체의 차이점은 정육면체의 길이, 높이 및 너비가 동일한 반면 직육면체에서는 이 세 가지가 동일하지 않다는 것입니다.
직육면체의 표면적은 다음 공식을 사용하여 계산됩니다. -
2*( length *width + width* height + height*length)
직육면체의 면적은 다음 공식을 사용하여 계산됩니다. -
length*width*height
아래는 동일한 데모입니다 -

입력
입력이 -
라고 가정합니다.Length= 6; Width= 7; Height= 8;
출력
원하는 출력은 -
Volume Of the Cuboid is : 336.0 Surface area Of the Cuboid is : 292.0
알고리즘
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
예시 1
여기에서 입력은 프롬프트에 따라 사용자가 입력하고 있습니다. 우리코딩 그라운드 도구에서 이 예제를 라이브로 사용해 볼 수 있습니다.
.
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);
}
} 출력
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
예시 2
여기서 정수는 이전에 정의되었으며 그 값은 콘솔에 액세스되어 표시됩니다.
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);
}
} 출력
The volume Of the Cuboid is:336.0 The surface area Of the Cuboid is:292.0