Given the dimensions of the cone, find the Surface area and Volume of a cone. The formula’s to calculate the area and volume are given below.

**Cone**

Cone is a three-dimensional geometric shape. It consists of a base having the shape of a circle and a curved side (the lateral surface) ending up in a tip called the apex or vertex.

Surface Area of Cone = Area of cone + Area of Circle = pi * r * s + pi * r^2

Volume of Cone = 1/3(pi * r * r * h)

where r is the radius of the circular base, h is the height (the perpendicular distance from the base to the vertex) and *s* is the slant height of the cone.

Slant height (s) can be calculated using Pythagoras formula sqrt(r * r + h * h)

Input: radius = 5 slant_height = 13 height = 12Output: Volume Of Cone = 314.159 Surface Area Of Cone = 282.743Input: radius = 6 slant_height = 10 height = 8Output: Volume Of Cone = 301.593 Surface Area Of Cone = 301.593

**Approach : **

- Given the dimensions of the cone, say radius R and height H of cone
- Find S = sqrt(R * R + H * H)
- Apply the above formulas

**Example 1:**

## Java

`// Java Program to Find the Surface Area and Volume of a` `// Cone` ` ` `import` `java.io.*;` ` ` `class` `GFG {` ` ` `public` `static` `void` `main(String[] args)` ` ` `{` ` ` `// specify radius and height of cone` ` ` `double` `R = ` `6` `, H = ` `8` `;` ` ` ` ` `// calculate slant height S` ` ` `double` `S = Math.sqrt(R * R + H * H);` ` ` ` ` `// calculate surface area of cone` ` ` `double` `SurfaceArea` ` ` `= (Math.PI * R * R) + (Math.PI * R * S);` ` ` ` ` `// calculate volume of cone` ` ` `double` `Volume = (Math.PI * R * R * H) / ` `3` `;` ` ` ` ` `System.out.println(` `"Surface area of cone is : "` ` ` `+ SurfaceArea);` ` ` ` ` `System.out.println(` `"Volume of cone is : "` `+ Volume);` ` ` `}` `}` |

**Output**

Surface area of cone is : 301.59289474462014 Volume of cone is : 301.59289474462014

**Example 2:**

## Java

`// Java Program to Find the Surface Area and Volume of a` `// Cone` ` ` `import` `java.io.*;` ` ` `class` `GFG {` ` ` `public` `static` `void` `main(String[] args)` ` ` `{` ` ` `// specify radius and height of cone` ` ` `double` `R = ` `3.42` `, H = ` `12` `;` ` ` ` ` `// calculate slant height S` ` ` `double` `S = Math.sqrt(R * R + H * H);` ` ` ` ` `// calculate surface area of cone` ` ` `double` `SurfaceArea` ` ` `= (Math.PI * R * R) + (Math.PI * R * S);` ` ` ` ` `// calculate volume of cone` ` ` `double` `Volume = (Math.PI * R * R * H) / ` `3` `;` ` ` ` ` `System.out.println(` `"Surface area of cone is : "` ` ` `+ SurfaceArea);` ` ` ` ` `System.out.println(` `"Volume of cone is : "` `+ Volume);` ` ` `}` `}` |

**Output**

Surface area of cone is : 170.81027853689216 Volume of cone is : 146.98129725379061

**Time Complexity = **O(1)

Attention reader! Don’t stop learning now. Get hold of all the important **Java Foundation** and Collections concepts with the **Fundamentals of Java and Java Collections Course** at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer **Complete Interview Preparation Course****.**