# Java Program to Calculate Total Surface Area and Curved Surface Area of cylinder

Hi friends! In this tutorial, we’ll be learning how to write a Java program to calculate total surface area and curved surface area of cylinder. If you remember from our previous tutorial, we learned how to write a Java Program to calculate Surface Area and Volume of Sphere. If you haven’t checked it out yet, I recommend taking a look at it.

Before moving ahead and writing our program, first, we need to know the mathematical formula and concept behind it to calculate the total surface area and curved surface area of the cylinder.

## Curved Surface Area of Cylinder

The curved surface area (CSA), also known as the lateral surface area (LSA), of a cylinder is determined by measuring the curved surface of the cylinder with a base radius ‘r’ and height ‘h’. The mathematical formula for calculating the curved surface area or lateral area is as follows:

Curved Surface Area of Cylinder = 2πrh Square units

where,

• π is a constant whose value is 22/7 or 3.1415
• r is the base radius of the cylinder
• h is the height of the cylinder

## Total Surface Area of Cylinder

The total surface area of a cylinder can be calculated by adding up the areas of all its faces. For a cylinder with a radius ‘r’ and height ‘h’, the total surface area is the sum of the curved surface area and the areas of the circular bases of the cylinder.

Total Surface Area of Cylinder = Curved Surface Area + Areas of circular bases
Total Surface Area of Cylinder = 2πrh + 2πr
Total Surface Area of Cylinder = 2πr(h + r) Square units

where,

• π is a constant whose value is 22/7 or 3.1415
• r is the base radius of the cylinder
• h is the height of the cylinder

Now let’s learn how to calculate them in Java programming.

## Java Program to Calculate Total Surface Area and Curved Surface Area of Cylinder

### What we did?

We have written Java program to calculate total surface area and curved surface area of cylinder successfully. Now we will explain what we did in our program.

• First of all we imported the util package.
• Then we have created a public class named as Cylinder.
• Inside Cylinder class we created main() method.
• Then we have declared variables which are used in this program.
• Now we created object of the Scanner class.
• Then asked the user to enter the radius and height of the cylinder.
• In next line read the value of radius and height entered by the user.
• Then calculated curved suface area of the cylinder using formula 2*Math.PI * radius*height. Instead of using Math.PI we can also write the value of pi (3.14 or 22/7) directly.
• In next line calculated total surface area of the cylinder using formula 2 * Math.PI * radius*(height+radius).
• Then at last printed curved surface area and total surface area of the cylinder on screen.

Output

Now this tutorial on Java Program to calculate total surface Area and curved surface area of cylinder is completed. In the upcoming tutorials, we will delve into a series of Java programs dedicated to solving numerical problems.

Related Tutorials…