Write a program to display the volume of cube, Cylinder and cone with the help of given formula, taking necessary inputs. 1. Volume of cube = side3 2. Volume of cylinder = πr2h 3. Volume of cone = 1/3 πr2h
Answers
Programs : {JAVA}
Write a program to display the volume of cube.
public class cube{
public static void main(String args[])
{
int s=4;
int volume=s*s*s;
System.out.println("Volume of the cube="+volume);
}
}
Write a program to display the volume of cylinder.
public class cuboid
{
public static void main(String args[])
{
{Scanner s= new Scanner(System.in);
System.out.println("Enter the length of Cubiod:");
double l=s.nextDouble();
System.out.println("Enter the breadth of Cubiod:");
double b=s.nextDouble();
System.out.println("Enter height of Cubiod:");
double h=s.nextDouble();
double volume= l*b*h;
System.out.println("Volume Of Cuboid is:" +volume);
}
}
Write a program to display the volume of cone.
public class cone
{
int main()
{
int height=38;
int radius=35;
double pie=3.14285714286;
double volume=pie*(radius*radius)*height/3;
printf("Volume of the cone=%f",volume);
}