8. JAVA Program to find Volume of a Cylinder.
How does this program work?
- In this programme you will learn about how to calculate Volume of a Cylinder.
- This programme requires the user input to enter the Radius and Height of a Cylinder.
- This programme perform mathematical calculation and display the result using java.
Here is the code
// Volume of a Cylinder
import java.util.Scanner;public class volume
{
public static void main(String args[])
{
int r,h,c;
double volume ,pi=3.14;
System.out.println("Enter the Radius of a Cylinder : ");
Scanner obj1=new Scanner(System.in);
System.out.println("Enter the Height of a Cylinder : ");
Scanner obj2=new Scanner(System.in);
r=obj1.nextInt();
h=obj1.nextInt();
volume=pi*r*r*h;
// Formula for volume of cylinder
System.out.println("Volume of a Cylinder is: " +volume);}
}