Programming Examples

Java program to input the radius and height of a cylinder and find its volume and total surface area


Write a program to input the radius and height of a cylinder and find its volume and total surface area.

Note: Total Surface Area=22 + 2h

Volume=2h

Solution

import java.util.*;
class AreaCylinder 
{
	public static void main(String arr[])
	{
		Scanner sc=new Scanner(System.in);
		float r,h,v,a,pi=3.142f;
		System.out.println( “Enter the radius:”);
		r=sc.nextFloat();
		System.out.println( “Enter the height:”);
		h=sc.nextFloat();
		v=pi*r*r*h;
		a=2*pi*r*r+2*pi*r*h;
		System.out.println( “ Volume=”+v);
		System.out.println( “Area=”+a);
	}
}
Output

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad