Question: Write a short program that computes the volume of a sphere given the radius. Your program should have a prompt asking the user to input

Write a short program that computes the volume of a sphere given the radius.

Your program should have a prompt asking the user to input the value of the radius, calculate the the volume of the sphere, and then output the volume to the console with a label.

Output should be rounded to 2 decimal places. Wikipedia can be used to find the equation for the sphere volume. Use a named constants for PI instead of hard coding 3.14 in your math expression. Try to use good variable names.

Using a calculator work out the solution for a certain radius. Verify that you get the correct result with your program. Don't forget that dividing two integers (like 4/3) does not produce a result with a decimal (like 1.33). To do floating-point division at least one number needs a decimal point (like 4.0/3).

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 Databases Questions!