Question: 1 . Write a complete JavaScript program to prompt the user for the radius of a sphere, and call function sphereVolume to calculate and display
Write a complete JavaScript program to prompt the user for the radius of a sphere, and call
function sphereVolume to calculate and display the volume of the sphere. Use the statement
volume Math.PI Math.pow radius, ;
to calculate the volume. The user should enter the radius in an HTML input element of type
"number" in a form. Give the input element the id value "inputField". You can use this id with
the document objects getElementById method to get the element for use in the script. To access the
string in the inputField, use its value property as in inputField.value, then convert the string to
a number using parseFloat. Use an input element of type "button" in the form to allow the user
to initiate the calculation. Note: In HTML input elements of type "number" have a property
named valueAsNumber, that enables a script to get the floatingpoint number in the input element
without having to convert it from a string to a number using parseFloat. At the time of this writing,
valueAsNumber was not supported in all browsers.
Embedded JS code in HTML with execution screenshots
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
