Java Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 5: Write a Java program to calculate the Surface Area of the Cuboid.

SurfaceArea.java

import java.util.Scanner;

public class SurfaceArea
{
	public static void main(String[] args)
	{
		//Declaring Variables
		Scanner sc =new Scanner(System.in);
		double length;
		double width;
		double height;
		double surfaceArea;
	
		System.out.println("Enter the length of the cuboid");
		length=sc.nextDouble();
		System.out.println("Enter the width of the cuboid");
		width=sc.nextDouble();
		System.out.println("Enter the height of the cuboid");
		height=sc.nextDouble();
		
		surfaceArea = 2*(length*width + width*height + height*length);
		System.out.println("Surface Area: "+surfaceArea);
	}
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.