Question: 1 . This is a bit different from your earlier work as you are not writing a new program this time. Recall this program, which
This is a bit different from your earlier work as you are not writing a new program this time. Recall this program, which finds the volume of a cone given the radius and height as inputs, using the formula Volume PI radius squared height
Cone Volume Calculator Program
Intro C
Written by Bill H August
#include
using namespace std;
int main
Declare variables and constants
double coneRadius ;
double coneHeight ;
const double PI ;
double coneVolume ;
Prompt the user for inputs
cout "Enter the radius of the cone: ;
cin coneRadius;
cout "Enter the height of the cone: ;
cin coneHeight;
Do the calculation
coneVolume PI coneRadius coneRadius coneHeight;
Display the result
cout "The volume of your cone is: coneVolume endl;
systempause;
return ;
end of main
For this assignment, we want the program to do the same thing, but with not one main function, but instead one main function PLUS one user defined function called computeConeVolume that contains the calculation. In other words, remove the one line calculation, replace it with a function call, then write and add the function below main with the calculation, surrounded any other syntax you need to complete it Determine how to do all that.
Notes:
The function should contain local variables and a constant declared and must have the calculation, it may not do anything else such as input or output.
You may not declare "global" variables anywhere. No variables above or outside of main and the function are allowed.
You may NOT use the same variable names for the cone parameters in main and in the function. They must be different, but still descriptive.
A valuereturning function should be used because it's a little simpler to understand, but you can employ a void function if you desire.
Be sure to have a function prototype at the top of the code, then main, then your function.
Functions need comments just like all code does.
Think carefully about where you include universal constants like PI you include it only once in your program, but there is a "good" way to use it and a "bad" way, even though both ways can work. You are expected to use the "good" way.
You may test your code by entering and running the original program with only main then comparing the results to your new program.
Test with "real" numbers including decimals, like and
Don't use anywhere that number is so simple it can give the right answer sometimes if the program is wrong.
Remember, a function that isn't called isn't used!
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
