In: Computer Science
Part One: Write an interactive program to calculate the volume and surface area of a three-dimensional object. Use the following guidelines to write your program:
Part Two: Code the program. Use the following guidelines to code your program.
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
#code
# value for pi
pi = 3.14
def surfaceArea(radius, height):
'''
this method calculates the surface area of a
cylinder with
given radius and height
'''
area = (2 * pi * radius * radius) + (2 * pi
* radius * height)
return area
def volume(radius, height):
'''
this method calculates
the volume of a cylinder with
given radius and
height
'''
vol = pi * radius * radius * height
return vol
def main():
# printing description
print('THIS PROGRAM CALCULATE THE
SURFACE AREA & VOLUME OF A CYLINDER')
# print your name and other details
here.
# getting radius and height from user
radius = float(input('Enter the
radius: '))
height = float(input('Enter the height:
'))
# finding and displaying area and
volume
area = surfaceArea(radius, height)
vol = volume(radius, height)
print('The surface area is:',
area)
print('The volume is:',
vol)
# calling main()
main()
#output
THIS PROGRAM CALCULATE THE SURFACE AREA & VOLUME OF A CYLINDER
Enter the radius: 25
Enter the height: 60
The surface area is: 13345.0
The volume is: 117750.0
#pseudocode (plain english)
1. Initialize Pi to 3.14
2. Read radius, height
3. Set area = (2 * pi * radius * radius) + (2 * pi * radius * height)
4. Set volume = pi * radius * radius * height
5. Display area, volume
6. Quit