Write a function area that calculates the area of a circle. The function is given the radius of the circle.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<body>
<script language="JavaScript">
function CircleArea(){
var radius =document.form1.foo.value;
document.write("<p>The area " + (radius * radius * Math.PI) + "</p>");
document.write("<p>The Circumference " + (2 * radius * Math.PI) + "</p>");
}
</script>
<form name=form1>
Enter the radius of circle:
<input type="text" name="foo" size=10>
<br>
<input type="button" value="Calculate" onClick='CircleArea();'>
</form>
</script>
</body>
</body>
</html>
Comments
Leave a comment