Question

In: Computer Science

Write a JavaScript function to calculate the surface area of a sphere. Input the radius using...

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.

Solutions

Expert Solution

<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:


Related Solutions

Write a C++ program to calculate the sphere volume and surface area. Provided that the sphere...
Write a C++ program to calculate the sphere volume and surface area. Provided that the sphere volume = and the sphere surface area = , where r is the radius. 1. Read r from the user using cin statement. 2. Calculate the volume (Vol) and the surface area (Area) of a sphere. 3. Print r, Vol, and Area in a suitable messages.
The surface area of a sphere of radius r is S = 4πr2. Its volume is
The surface area of a sphere of radius r is S = 4πr2. Its volume is V = 4πr3/3. a. Use MuPAD to find the expression for dS/dV. b. A spherical balloon expands as air is pumped into it. What is the rate of increase in the balloon’s surface area with volume when its volume is 30 in.3?
(i) Find the cylinder inscribed in a sphere with radius one with the largest surface area.
(i) Find the cylinder inscribed in a sphere with radius one with the largest surface area.
A sphere of radius r has surface area A = 4πr2 and volume V = 4...
A sphere of radius r has surface area A = 4πr2 and volume V = 4 3 πr3. The radius of sphere 2 is triple the radius of sphere 1. (a)What is the ratio of the areas, A2/A1? (b) What is the ratio of the volumes, V2/V1?
Write a 'C' program to calculate the surface area of the cone and by using that,...
Write a 'C' program to calculate the surface area of the cone and by using that, also calculate the volume of the cone and print the values as surface area of the cone and volume of the cone. where as: surface area of the cone = πr2 (r is the radius of the surface) volume of the cone = (1/3)πr2h (h is the height of the cone)
Using a scalar surface integral, compute the surface area of the portion of the unit sphere...
Using a scalar surface integral, compute the surface area of the portion of the unit sphere that is above the cone z = sqrt(x^2+y^2)
Write a program that reads the radius of a sphere and calculates it's volume and surface...
Write a program that reads the radius of a sphere and calculates it's volume and surface area. Format results to 4 decimal places. The radius=3.2 Your program should output volume and surface area.  Repeat same steps for program2, but this time use the following input values: a= ꟷ2.4 , b = 4.5 . Your program should output sum, Fun1, and Fun2. It's for C++
Find the distribution of temperature inside a sphere of radius a when the surface of the...
Find the distribution of temperature inside a sphere of radius a when the surface of the upper half is held at 100°C and the surface of the lower half at 0°C
Write a JavaScript function to get the values of form containing the following input fields: fname...
Write a JavaScript function to get the values of form containing the following input fields: fname lname address city state
Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm...
Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm with the substitution algorithm. Specify the min and max of the message user can enter to encrypt. Specify the length of the key user can enter to encrypt and decrypt the message. document your design by words or diagrams.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT