Advertisement
dimipan80

Cylinder Volume

Nov 9th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Write a JavaScript function calcCylinderVol(arr) that accepts the following parameters:
  2. radius and the height of a straight circular cylinder. The function calculates
  3. the volume of the cylinder. Write JS program cylinderVol.js that calculates the volume of
  4. a few cylinders. The result should be printed on the console. */
  5.  
  6. "use strict";
  7.  
  8. function calcCylinderVol(arr) {
  9.     return Math.PI * arr[0] * arr[0] * arr[1];
  10. }
  11.  
  12. console.log(calcCylinderVol([2, 4]).toFixed(3));
  13. console.log(calcCylinderVol([5, 8]).toFixed(3));
  14. console.log(calcCylinderVol([12, 3]).toFixed(3));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement