Enter the length, breadth and height as input. Now we calculate the volume and area by using formula and get the desired output.
Here is the source code of the Java Program to Find the Volume and Surface Area of Cuboids. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Volume_SurfaceArea
public static void main(String args)
int l, b, h;
Scanner s = new Scanner(System.in);
System.out.print("Enter the length of cuboid:");
l = s.nextInt();
System.out.print("Enter the breadth of cuboid:");
b = s.nextInt();
System.out.print("Enter the height of cuboid:");
h = s.nextInt();
area = 2 * ((l * b) + (b * h) + (h * l));
System.out.println("Surface Area of cuboid:"+area);
volume=l * b * h;
System.out.println("Volume of cuboid:"+volume);
$ javac Volume_SurfaceArea .java $ java Volume_SurfaceArea Enter the length of cuboid:4 Enter the breadth of cuboid:5 Enter the height of cuboid:6 Surface Area of cuboid:148.0 Volume of cuboid:120.0
Sanfoundry Global Education & Learning Series – 1000 Java Programs.