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

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz