Use Math.round to calculate area : round « Math « JavaScript Tutorial






<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
function calcArea()
{
    inpRadius = 3;
    alert(Math.round(Math.PI * ((inpRadius)*(inpRadius))));
}

function calcPeri()
{
    inpRadius = 3;
    alert(Math.round(2 * Math.PI * (inpRadius)));
}

function calcVol()
{
    inpRadius = 3;
    alert(Math.round(Math.PI * ((inpRadius)*(inpRadius)*(inpRadius)) * (4/3)));
}
//  -->
</script>
</head>
<body>
<h1>All about Circles and Spheres!</h1>
<P>Click <input type="button" value="HERE" onclick="calcArea();"> to calculate circle area!</p>
<br>
<P>Click <input type="button" value="HERE" onclick="calcPeri();"> to calculate circle perimeter!</p>
<br>
<P>Click <input type="button" value="HERE" onclick="calcVol();"> to calculate sphere volume!</p>
</body>
</html>








9.22.round
9.22.1.Math.round()
9.22.2.Rounding a number to an integer
9.22.3.Use Math.round to calculate area