1) This is a bit different from your earlier work as you are not writing a new...
Question:
1) This is a bit different from your earlier work as you are not writing a new program this time. Recall the Cone Volume Calculator program from earlier Instructor Comments:
//Cone Volume Calculator Program
// Intro C++, Lesson 4
// Written by Bill H, Nov 2013
#include <iostream>
using namespace std;
int main( )
{
//Declare variables and constants
double coneRadius = 0.0;
double coneHeight = 0.0;
const double PI = 3.1415;
double coneVolume = 0.0;
//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 = 0.3333 * PI * coneRadius * coneRadius * coneHeight;
//Display the result
cout << "The volume of your cone is: " << coneVolume << endl;
system("pause");
return 0;
} //end of main
2) 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. Note that recent sample programs can be of a real help to you here, in addition to the book, of course.
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.
* A value-returning 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.
* You may test your code by copying and running the original program ( with only main() ), then comparing the results to your new program.
* Test with "real" numbers including decimals, like 3.4 and 5.8
* Don't use 1 anywhere - that number is so simple it can give the right answer sometimes if the program is wrong.
Managerial Accounting for the Hospitality Industry
ISBN: 978-1119386223
2nd edition
Authors: Lea R. Dopson, David K. Hayes