Hello everyone, my problem that I'm have is that I have to get the volume and the surface area of a sphere using a class. I believe I was able to do that part of the problem correctly. The issue I'm having is getting that information to print from the class.
Basically all I need to do now is to get volume and surface area to print.
Here is the code I'm coming up with:
import string
import math
#import systemexit thingy
class solidsphere:
def __int__(self,radius):
self.radius2 = float(radius2)
def getRadius(self):
return self.radius2
def surfaceArea(self):
area = 4*math.pi*self.radius2**2
self.area = area
print self.area
return self.area
def volume(self):
volume = (4/3)*math.pi*self.radius2**3
self.volume = volume
print self.volume
return self.volume
#def radiusInput():
# radius = input("Enter in the radius of the sphere: ")
# return (radius)
#If radius is negative return error message
def radiuscheckuserinput(radius2):
if radius2 <= 0:
print "See next line"
print "See next line"
print "See next line"
print "See next line"
print "Error"
print "You did something wrong"
print "Do you feel bad about what you did?"
print "Well you should!"
print "You did not enter a valid radius"
print "Radius must be a positive number not a negative"
if radius2>= 0:
print "acceptable value"
#def sphereoutput():
# return solidsphere(Radius2, volume, surfaceArea)
# print s.radius2()
# print s.area()
# print s.volume()
def main():
radius = input("Enter in the radius of the sphere: ")
#print "The surface area of the sphere is", surfaceArea()
#print "The volume of the sphere is", volume()
#radius = radiusInput()
#print radius
radius2 = radiuscheckuserinput(radius)
print radius2
#area = surfaceArea(self)
#print self.area
#volume = volume(self)
#print self.volume
main()
thanks for your help. I feel like the solution is just sitting right infront of me but I'm just not recognizing it!