willsmaddison
New member
My Javascript code within my html file looks like this (yes there are html and body tags, dont worry about them).
<script type="text/javascript">
var circumference = window.prompt ( "Enter the circumference of the bottle (cm)" ,"0");
var height = window.prompt ( "Enter the height of the bottle (cm)" ,"0");
var radius = ( circumference/2 );
var PI = ( math.PI );
var surfacearea = ( 2*PI*radius*radius* );
if ( surfacearea < 100 )
{
document.write("The surface area was " + surfacearea + "cm^2.");
document.write("This will cost you £5.");
}
else if (surfacearea < 250)
{
document.write("The surface area was " + surfacearea + "cm^2.");
document.write("This will cost you £10.");
}
else if (surfacearea > 250)
{
document.write("The surface are was " + surfacearea + "cm^2.");
document.write("This will cost you £30.");
}
</script>
The script is supposed to ask the user to input the height and circumference of a bottle, and depending on the surface area, it will be priced accordingly. But this just doesn't work ¬_¬
Cheers to fantabulum for the answer :-D
<script type="text/javascript">
var circumference = window.prompt ( "Enter the circumference of the bottle (cm)" ,"0");
var height = window.prompt ( "Enter the height of the bottle (cm)" ,"0");
var radius = ( circumference/2 );
var PI = ( math.PI );
var surfacearea = ( 2*PI*radius*radius* );
if ( surfacearea < 100 )
{
document.write("The surface area was " + surfacearea + "cm^2.");
document.write("This will cost you £5.");
}
else if (surfacearea < 250)
{
document.write("The surface area was " + surfacearea + "cm^2.");
document.write("This will cost you £10.");
}
else if (surfacearea > 250)
{
document.write("The surface are was " + surfacearea + "cm^2.");
document.write("This will cost you £30.");
}
</script>
The script is supposed to ask the user to input the height and circumference of a bottle, and depending on the surface area, it will be priced accordingly. But this just doesn't work ¬_¬
Cheers to fantabulum for the answer :-D