# Java Program to Calculate Volume and Surface Area of Cone

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.
• Base area of cone = ΠR2
• Curved surface area of cone = ΠRS
Total surface area of cone = Base area + Curved area = ΠR2 + Π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.

## 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) {
Scanner scanner;
scanner = new Scanner(System.in);
// Take input from user
System.out.println("Enter the Base Radius of Cone");

System.out.println("Enter the Height of Cone");
height = scanner.nextDouble();

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
 Java Program to Find Surface Area and Volume of Cylinder Java Program to Find Volume and Surface Area of Cuboid Java Program to Calculate Surface Area and Volume of Cube Java Program to find Area Of Equilateral Triangle Java Program to Find Area Of Triangle Java Program to Find Area Of Trapezoid Java Program to Find Area of Right Angled Triangle Java Program to calculate area and circumference of circle Java Program to Calculate Volume of Sphere Java Program to Print Pascal Triangle Java Program to Print Pyramid Pattern of Stars All Java Programs