In: Computer Science
Write a JavaScript function to calculate the surface area of a sphere. Input the radius using a NumericUpDown. Have the function calculate the surface area and display it on your page. Label the inputs and the output on your page. Change the title to "Oh, Boy! JavaScript!". Put your name at the top in camelCase. Put your major at the bottom in camelCase.
<html>
<head>
<title>Oh, Boy! JavaScript!</title>
<script>
// Javascript function to calculate the surface area of a
spher
function surfaceAreaSphere()
{
var radius =
Number(document.getElementById("radius").value);
var surface_area = (4*22*radius*radius)/7;
document.getElementById("result").innerHTML =
surface_area.toFixed(2)+" ";
}
</script>
<style>
#footer{
position:absolute;
bottom:0;
}
#header{
position : absolute;
top:0;
}
</style>
</head>
<body>
<div id="header">Name in Camel
case</div><br/>
<h3>Calculate Surface Area of
Sphere</h3></br/><br/>
<label> Radius : </label><br/>
<input type="number" name="radius" id="radius"
value="0"/><br/><br/>
<button
onclick="surfaceAreaSphere()">Calculate</button><br/><br/>
<label> Surface Area : </label></br/>
<p id="result" name="result"></p>
<div id="footer">Major</div>
</body>
</html>
Output: