Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SodaCan:
- def __init__(self, h, r):
- self.radius = r
- self.height = h
- self.area = 0
- self.volume = 0
- def getRadius(self):
- return self.radius
- def getHeight(self):
- return self.height
- def surfaceArea(self):
- r=self.radius
- h=self.height
- self.area = (2 * 3.14 * r* h) + (2 * 3.14 * (r * r))
- return (self.area)
- def getVolume(self):
- r=self.radius
- h=self.height
- self.volume = 3.14 * (r * r) * h
- return (self.volume)
- def main():
- r = input("Enter the radius of the SodaCan: ")
- h = input("Enter the height of the SodaCan: ")
- can = SodaCan(h,r)
- print("The volume of the SodaCan is: ", can.surfaceArea())
- print("The surface area of the SodaCan is: ", can.volume())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement