Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design a function named print_surface_area that will calculate the surface area of a cylinder given the height of the cylinder is 6m and the diameter
Design a function named print_surface_area that will calculate the surface area of a cylinder given the height of the cylinder is 6m and the diameter is 5m (diagram shown below). diameter height Ensure you adhere to the function specifications described here: a) Implement the print_surface_area function as follows: o Create 2 variables: one for height and set it to 6 and another for diameter and set it to 5. o Using the diameter and the value of II, write a statement to calculate the circumference of the cylinder and store the result to a variable that you create. For the value of II you are free to create a symbolic constant or use the constant in C's math library if you are familiar with this but it is not necessary. o Using the diameter and the value of II, write a statement to calculate the area of the top of the cylinder and store the result to a variable. o Using the height and the circumference you calculated earlier, write a statement to calculate the area of the walls of the cylinder. o Using the 2 variables created above that are storing the area of the top and the area of the walls, write the lines of code to calculate the total surface area of the cylinder. o Print the resulting area to the screen with 2 significant figures and the units as shown in the sample output below. o Don't forget the cylinder has a top and a bottom b) Edit and run your program until your output is as shown in the image below. The accuracy of your calculation can vary as it will be dependent on the value you used for II. In the test run for the output shown below, we defined II with 2 significant figures (3.14) 133.45 square meters NOTE: There are other algorithms to calculate the surface area of a cylinder but we are asking you to follow this algorithm to give you practice with the creation and use of variables
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