Question: If programming a class to represent a geometry calculator, which class containing methods with parameters could be used to calculate the volume of a cube

If programming a class to represent a geometry calculator, which class containing methods with parameters could be used to calculate the volume of a cube with length l, width w and height h; the volume of a cylinder with radius r and height h; and increment the total number of calculations performed?
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self):
numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self):
numOfCalcs +=1
return math.pi * r * r * h
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self,l,w,h):
numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self,r,h):
numOfCalcs +=1
return math.pi * r * r * h
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self,l,w,h):
self.numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self,r,h):
self.numOfCalcs +=1
return math.pi * r * r * h
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self):
self.numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self):
self.numOfCalcs +=1
return math.pi * r * r * h

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!