当前位置:网站首页>JS calculate the circumference and area of the circle
JS calculate the circumference and area of the circle
2022-04-22 23:13:00 【Did you add pepper?】
subject : Calculate the circumference and area of a circle
I just studied recently js, Just do the exercises in the book .
<!DOCTYPE html >
<html>
<head>
</head>
<body>
<!-- Calculate the circumference and area of a circle -->
<div>
<p> Perimeter :<input id="zc" type="text" value=" Perimeter " ></p>
<p> area :<input id="mj" type="text" value=" area " ></p>
</div>
<script>
var a = parseFloat(prompt(" Please enter the radius of the circle :"))
const p = 3.14 // because Π It is the same. , So I set it as a constant
var b = 2*p*a// Perimeter
var c = a*p*a// area
if(Boolean(a)){
// Determine whether it is null
if( isNaN(a)){
// Determine whether it is a value
alert(" Input error ")
}
else{
document.getElementById("zc").value = b.toFixed(2)//toFixed(2) Simplify two decimal places
document.getElementById("mj").value = c.toFixed(2)
}
}
</script>
</body>
</html>
Running results :


Xiaobai's ideas and methods , Simple is good

版权声明
本文为[Did you add pepper?]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222309549553.html
边栏推荐
- 想开户交易农产品期货如玉米、豆粕等,该如何开户?
- Day81(动态规划、十叉树遍历)
- News Express I mobtech passed the "special safety evaluation" of China Academy of information and communications
- [BJDCTF2020]Easy MD5
- [Error]dyld: Library not loaded:
- [Swift]代碼觸發UIButton的點擊事件
- MySQL最新教程通俗易懂
- 解决require is not defined的报错问题
- Basic knowledge of SQL database
- 伦敦金在哪里开户安全些?
猜你喜欢
![Le Code [SWIFT] déclenche l'événement de clic d'uibutton](/img/23/444cfab44afe32d0476ba26f64bfdf.png)
Le Code [SWIFT] déclenche l'événement de clic d'uibutton
![[Swift]代码触发UIButton的点击事件](/img/23/444cfab44afe32d0476ba26f64bfdf.png)
[Swift]代码触发UIButton的点击事件

WebRTC系列-WebRTC基础(七)NAT、stun和turn(2)

SQL语言详解

codeforce round#784(div4) A-H

How to obtain geographical location based on photos and how to prevent photos from leaking geographical location

正则表达式——IP地址匹配

Online yaml to XML tool

Basic use and principle of Minio

The article "fluent" is used to select and upload pictures
随机推荐
.net 6 在退出构造函数时,不可为 null 的 属性“xxx”必须包含非 null 值。
Vtkvertex vertex
GBase 8a常用并行度参数调整提升性能
安全产品设计的重要性
SQL语言详解
JS有红,白,黑三球若干个,其中红,白球共25个,白黑共31个,红黑共28个,求三种球各多少个。
存储器简介
mysql索引详解
Redis部署
JS计算圆的周长和面积
Go语言-使用协程高效计算0-2000内每个数的累加
Core technology of GDB debugger - ptrace system call and use example
操作系统知识点(可学习,可复习,可面试)
[Swift]代碼觸發UIButton的點擊事件
How to install cadence software
[reproduction of thesis code] errors encountered in the translation embeddings for modeling multi relational data
[HCTF 2018]admin之Flask之session伪造
STM32 memory allocation analysis and variable storage location
L1-049 天梯赛座位分配 (20 分)( for循环的深入理解+三维数组+错误分析)
Read software engineering at Google (14)