Here is a Java Program to find the total surface area and volume of cone. In this java program, we have to calculate the volume and total surface area of a cone, given the base radius and height of the cone. A cone is an three-dimensional geometric shape having circular base and only one vertex. We can say that a cone have a flat circular base and having one slant curved surface.
Total Surface Area of Cone
A cone is a combination of two surfaces, the curved top section with slanted height and the circular base. The total surface area of cone is sum of area of the area of circular base and area of top curved section.
A cone is a combination of two surfaces, the curved top section with slanted height and the circular base. The total surface area of cone is sum of area of the area of circular base and area of top curved section.
- Base area of cone = ΠR2
- Curved surface area of cone = ΠRS
Volume of Cone
To calculate the volume of a right circular cone, we need radius of base and height of cone. Volume of a cone is one third of volume of a cylinder of same radius and height. Volume of right circular cone = (Base area x Height)/3;
As base of cone is circular, Base Area = ΠR2
Then, Volume of right circular cone = (ΠR2H)/3
Where 'R' is the radius of the base and 'H' is the height of cone.
To calculate the volume of a right circular cone, we need radius of base and height of cone. Volume of a cone is one third of volume of a cylinder of same radius and height. Volume of right circular cone = (Base area x Height)/3;
As base of cone is circular, Base Area = ΠR2
Then, Volume of right circular cone = (ΠR2H)/3
Where 'R' is the radius of the base and 'H' is the height of cone.
Java program to calculate the volume and surface area of cone
In this java program, we first take base radius and height of cone as input from user and then calculate volume and surface area using above mentioned mathematical expressions.
package com.tcc.java.programs; import java.util.Scanner; public class VolumeOfCone { public static void main(String[] args) { double radius, height, volume, surfaceArea; Scanner scanner; scanner = new Scanner(System.in); // Take input from user System.out.println("Enter the Base Radius of Cone"); radius = scanner.nextDouble(); System.out.println("Enter the Height of Cone"); height = scanner.nextDouble(); surfaceArea = Math.PI * radius * (radius + Math.sqrt( height * height + radius * radius)); volume = 1.0 / 3 * (Math.PI * radius * radius * height); System.out.format("Surface Area of Cone = %.3f\n", surfaceArea); System.out.format("Volume of Cone = %.3f\n", volume); } }Output
Enter the Base Radius of Cone 4 Enter the Height of Cone 7 Surface Area of Cone = 151.579 Volume of Cone = 117.286
Recommended Posts