做一道数学题,如何利用js计算圆柱体的体积,下面web建站小编给大家详细介绍一下实现代码!
计算圆柱体的体积:
function cylinderCount(height, diameter) { this.height = height; this.diameter = diameter; } cylinderCount.prototype.Volume = function () { var radius = this.diameter / 2; return this.height * Math.PI * radius * radius; }; var cyl = new cylinderCount(7, 4); console.log('圆柱体积:', cyl.Volume()); //圆柱体积: 87.96459430051421 //保留2位小数点 console.log('圆柱体积:', cyl.Volume().toFixed(2)); //圆柱体积: 87.96
上面是“数学题:利用js计算圆柱体的体积”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_3111.html
workflows工作流
森林里坐着一个外星人ComfyUI工作流
蘑菇屋,梦幻家园comfyui工作流
一条闪闪发光的金鱼ComfyUI工作流
一只放屁虫甲虫ComfyUI工作流
一只白色的孔雀ComfyUI工作流
一个孤独的斗篷人物站在一座巨大的雕塑旁
在森林中心有一座蛇形的房子ComfyUI工作流
爱因斯坦在做实验3d动漫ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!