In this post, we will see how to calculate total surface area of Cylinder in java.
Formula of calculating total surface area of Cylinder is:
Surface area of Cylinder = 2 *Î * r * r + 2 *Î * r * h
Where r is radius of cylinder and h is height of cylinder
Where r is radius of cylinder and h is height of cylinder
Here is java program to calculate total surface area of Cylinder. We are using scanner class to take input from user in below program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
package org.arpit.java2blog; import java.util.Scanner; public class TotalSurfaceAreaCylinderMain { public static void main(String[] args) { Scanner s= new Scanner(System.in); System.out.println("Enter the radius of cylinder :"); double r=s.nextDouble(); System.out.println("Enter the height of cylinder :"); double h=s.nextDouble(); double surfaceAreaOfCylinder= 2 * Math.PI * r * r + 2 * Math.PI * r * h; System.out.println("Total surface area of cylinder is: "+surfaceAreaOfCylinder); s.close(); } } |
When you run above program, you will get below output
Enter the radius of cylinder :
4
Enter the height of cylinder :
3
Total surface area of cylinder is: 175.92918860102841
4
Enter the height of cylinder :
3
Total surface area of cylinder is: 175.92918860102841
That’s all about how to calculate total surface area of cylinder in java.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.