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?
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++
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
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
Consider a particle which is constrained to move along the surface of the sphere of radius...
Consider a particle which is constrained to move along the surface of the sphere of radius 5, centered at the origin. (a) If we write r(t) for the motion, write down the condition ‘constrained to move along the surface of the sphere of radius 5 centered at the origin’ in terms of r(t). (Hint. For later use, try to get rid of square roots.) (b) Explain why, for such a motion, we must have r 0 (t) ⊥ r(t). (Hint....
7.1.2. A pulsating sphere of radius a vibrates with a surface velocity amplitude U0 and at...
7.1.2. A pulsating sphere of radius a vibrates with a surface velocity amplitude U0 and at such a high frequency that ka >> 1. Derive expressions for the pressure amplitude, the particle velocity amplitude, the intensity, and the total acoustic power radiated in the resulting acoustic wave.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT