
Concept explainers
(In Python 3)
For this assignment, you would use a menu driven option to calculate the volume and surface area of cylinder as well as a cone using functions.
Use the cylinder_volume(r, h) and the cylinder_surface_area(r, h) from Week 9 lab and expand your code to also calculate the surface area and the volume of the cone using functions.
Your tasks are as follows:
- Define a function called cone_volume(r, h) that that takes two arguments from user: radius r and height h, and prints the volume rounded to two decimal places (no need to return the value).
- Define a function called cone_surface_area(r, l) that takes two arguments from user: radius r and slant height l, and prints the surface area of the cone rounded to two decimal places (no need to return the value).
- Display a menu to ask the user to input their choice. Based on the choice selected, ask the user for corresponding input for r,h, and/or l. Inputs need to be float. Hint: you can input the values inside the if statements when comparing the options with the user's choice for the menu.
- Use default parameter values for all the functions of your choice.
Formulae:
Volume of a cone: 13πr2h13πr2h
Surface Area of a cone: πrl+πr2πrl+πr2
Volume of a cylinder: πr2hπr2h
Surface Area of a cylinder 2πr2+2πrh2πr2+2πrh
A sample run is show below:
**** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 1 Enter radius: 22.5 Enter height: 10.5 Volume of the cone for radius 22.5 and height 10.5 is: 5566.51 **** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 7 Wrong choice entered. **** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 5 Goodbye!

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images

- 8. Write a function with one parameter. The function should accept the value of a radius as its argument and return the volume of the sphere with that radius. Note that the radius may be a decimal fraction. The function should not read or print anything.arrow_forwardCan i please get help with this, thanksarrow_forwardWhat benefits can you get from using a function?\arrow_forward
- What benefits can you get from using a function?\arrow_forwardFor each of the 4 functions below, Re-code each one to make it programmer friendly, using standard coding conventions, and documentation. Document each function with: a description of what it does (one sentence) and how it works (no more than 3 sentences). Also, provide a precondition: and a postcondition: statement. (See example for the setTime function below.) 1. 2. setTime(int hours, int minutes, int seconds); //Function to set the time //The time is set according to the parameters //Precondition: All parameters are valid numbers, within the range of clock hours (1-12), minutes (0 - 59), and seconds (0 - 59). //Postcondition: The clockType instance stores the hours, minutes and seconds. // If any of the parameters are not valid the time values will be set to zeros. int _1 (double x) {return (int) (x + 0.5); }; int _2 (char* s) {char*t = s; while (*t!='\0') {t++; }return t-s;}; 3. long 3 (int x,int y) {long n=1; for (int i = 0;i < y;i++) {n*=x; } return n; };arrow_forwardPlease circle True or False for each of the following statements. C++ Local variables used in a function are defined in the parameter list of that functions definition. TRUE FALSEarrow_forward
- I need help with this questionarrow_forwardAlert dont submit AI generated answer. Please help fill in the code for the functions.The correct output is shown.arrow_forwardFor the following code can you change the factors that impact the total construction cost section into a function(define a function). Where the mean can be entered through by asking for the inputs of the mean value for each of the factors. (i.e., "Please enter the mean value for material", "Please enter the mean value for labour".. etc.). Follwoing this the standard deviation of the factors is calculated and this is all done in a function.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





