Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C + + program to compute the volume of a sphere ( Note: V = 4 3 pi r 3 ) .

Write a C++ program to compute the volume of a sphere (Note: V =4
3
\pi r
3
).
Define \pi as a global constant with the value 3.14159. Name it appropriately. Remember
that global constants should be defined before any function definitions. Make sure to
include 3 specific functions: (1) a function which prompts the user for the radius and
returns that value (radius should be a double); (2) a function which calculates the volume
for the provided radius; (3) a function to display the result. Please use function
declarations and comment that section appropriately. Also, before the body of each
function, please provide a brief 1-3 line comment describing the basic operation of the
function, including inputs and output.
Style:
2 points for comments: Every section should have at least a brief description of the lines
that follow. The very top of your code should contain your name, the name of the
program, and a brief description of what the program does and the important variables.
2 points for whitespace: Blank lines should precede all sections of code (compiler
directives like #include statements, variable declarations, calculations, all functions, etc).
Proper indentation must be used as appropriate.
1 point for variable names, constant names, program name, function names: All
variables and constants must be named appropriately. Names should be as short as
possible, while still being descriptive enough for someone else to understand. All
variables should be in lowercase, with the possible exception of the first letter of distinct
words, for example finalBalance. All constants should be in UPPERCASE. Your
program (.cpp file) should have a short, intuitive name. Good program names are
num_sum.cpp, sphere_calc.cpp, and so on. Please do not call it homework4.cpp or
anything similar. The same extends to functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

=+Write a paragraph on each aspect of each paper:

Answered: 1 week ago