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

1. 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 =(4.0/3.0)* Math.PI * Math.pow( radius, 3);
to calculate the volume. The user should enter the radius in an HTML5 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 HTML5 input elements of type "number" have a property
named valueAsNumber, that enables a script to get the floating-point 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!