Проблем със задача Cone. JS-Data-Types-And-Variables
Здравейте имам проблем със следната задача.Качвам условието и кодът ми. Благодаря.
- Cone
Write a function to calculate a cone’s volume and total surface area by given height and radius at the base.
The input comes as two number arguments. The first element is the cone’s radius and the second is its height.
The output should be printed to the console on a new line for every result. The result should be formatted to the fourth decimal point
Examples
Input |
Output |
|
Input |
Output |
3, 5 |
volume = 47.1239 area = 83.2298 |
|
3.3, 7.8 |
volume = 88.9511 area = 122.0159 |
Hints
You can use this online tool to check your results: http://www.calculatorsoup.com/calculators/geometry-solids/cone.php
function solve(r, h) {
let volu = (((Math.PI * r * r) * h) / 3).toFixed(4);
let str = 'volume'
console.log(`${str} = ${volu}`);
let s = Math.sqrt(r * r + h * h);
let arr = Math.PI * r * (r + s);
let str1 = 'area';
console.log(`${str1} = ${arr.toFixed(4)}`);
}