Java program to find the Surface Area and volume of the cylinder

Given the values of radius and height, we have to find the Surface Area and volume of the cylinder.
Submitted by Nidhi, on February 27, 2022

Problem Solution:

In this program, we will read radius, height from the user and calculate the area, volume of the cylinder.

Program/Source Code:

The source code to find the Surface Area and volume of the cylinder is given below. The given program is compiled and executed successfully.

// Java program to find the Surface Area 
// and volume of the cylinder

import java.util.Scanner;

public class Main {
  static float calcuateVolumeOfCylinder(float radius, float height) {
    float result = 0.0F;
    result = 3.14F * radius * radius * height;
    return result;

  static float calcuateAreaOfCylinder(float radius, float height) {
    float result = 0.0F;
    result = 2 * 3.14F * radius * (radius + height);
    return result;

  public static void main(String[] args) {
    Scanner SC = new Scanner(;

    float radius = 0;
    float height = 0;
    float volume = 0;
    float area = 0;

    System.out.printf("Enter the radius: ");
    radius = SC.nextFloat();

    System.out.printf("Enter the height: ");
    height = SC.nextFloat();

    volume = calcuateVolumeOfCylinder(radius, height);
    area = calcuateAreaOfCylinder(radius, height);

    System.out.printf("Volume of Cylinder is: %f\n", volume);
    System.out.printf("Surface area of Cylinder is: %f\n", area);


Enter the radius: 3
Enter the height: 7
Volume of Cylinder is: 197.820007
Surface area of Cylinder is: 188.399994


In the above program, we imported the "java.util.Scanner" package to read input from the user. And, created a public class Main. It contain three static methods calcuateVolumeOfCylinder(), calcuateAreaOfCylinder() and main().

The calcuateVolumeOfCylinder(), calcuateAreaOfCylinder() methods are used to calculate the volume and area of the Cylinder based on given radius and height.

The main() method is an entry point for the program. And, we read radius, height from the user using the Scanner class. Then we calculated the volume, area of the Cylinder using calcuateVolumeOfCylinder(), calcuateAreaOfCylinder() methods, and printed the result.

Java Basic Programs »


Comments and Discussions!


Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.