Click to See Complete Forum and Search --> : Circle area calculator


hitman
01-27-2003, 06:26 AM
Hi,

I am trying to do a little script that calculates the area of a circle. It prompts before to ask for the radius then calculates. Well, it is supposed to do that. I tried but it doesn't give anything on the page.

Can you please have a look to tell me what is wrong?


<html>

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

function doArea(num) {
var radius = prompt("Please enter the radius of the circle: ", "");
return (Math.PI * Math.pow(radius, 2));
}

</script>
</HEAD>

<BODY>

<script language="javascript">

var radius = prompt("Please enter the radius of the circle: ", "");
return (Math.PI * Math.pow(radius, 2));

document.write("The area of the circle is " + " ")

</form>
</body>
</html>

Charles
01-27-2003, 06:31 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example</title>
</head>
<body>
<script type="text/javascript">
<!--
document.write('<p>The area of the circle is ', Math.PI * Math.pow( prompt('Please enter the radius of the circle: ', ''), 2), '.</p>');
// -->
</script>
</body>
</html>