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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started